-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attribute values > to_phlex_attribute_value, to_str, to_s #629
Conversation
…ttribute_value` or `to_str`, falling back to `to_s` if neither is defined
This looks good to me. I’m happy with |
lib/phlex/sgml.rb
Outdated
v.to_s | ||
end | ||
|
||
buffer << " " << name << '="' << ERB::Escape.html_escape(value) << '"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need to be updated because of a change I made.
buffer << " " << name << '="' << ERB::Escape.html_escape(value) << '"' | |
buffer << " " << name << '="' << Phlex::Escape.html_escape(value) << '"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @joelmoss. Unless anyone else has any comments, I’m happy to go with this.
Signed-off-by: Joel Drapper <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! Thanks for doing this! I left one note on the tests to ensure that they're testing for precedence
class ToPhlexAttributeValueable | ||
def to_phlex_attribute_value | ||
"to_phlex_attribute_value" | ||
end | ||
end | ||
|
||
class ToSable | ||
def to_s | ||
"to_s" | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that we can test for method precedence as well, what do you think about making these test classes build on each other like this:
class ToPhlexAttributeValueable | |
def to_phlex_attribute_value | |
"to_phlex_attribute_value" | |
end | |
end | |
class ToSable | |
def to_s | |
"to_s" | |
end | |
end | |
class ToPhlexAttributeValueable < ToSable | |
def to_phlex_attribute_value | |
"to_phlex_attribute_value" | |
end | |
end | |
class ToSable < ToStrable | |
def to_s | |
"to_s" | |
end | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but not sure it's necessary. The code is hugely simple, so I think testing much more than the existence of the methods has very little benefit.
Happy to add if that's the consensus.
Oh, good point re tests. I’ll open an issue for that since I merged this already. |
Fixes #569
Attribute values can be any object that responds to
to_phlex_attribute_value
orto_str
, falling back toto_s
if neither is defined.