-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add an ability to create custom components #102
base: develop
Are you sure you want to change the base?
Conversation
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.
Fabulous stuff 🎆
The result is really nice.
At first sight, I just have a few minor things.
We don't have a rubocop check, but I notice that your editor isn't configured to insure there's a <cr>
at the end of files. Ideally that would be fixed too.
INTERIM_TH_TAG_REGEX = %r{(?<=\<|\<\/)#{Regexp.escape(INTERIM_TH_TAG)}} | ||
|
||
DEFAULT_COMPONENTS = { | ||
"button" => Inky::Components::Button, |
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.
Might as well be consistent and use ::Inky...
self.components = DEFAULT_COMPONENTS | ||
.merge(options[:components] || ::Inky.configuration.components) | ||
.transform_values { |component_class| component_class.new(self) } | ||
.with_indifferent_access |
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.
Best not use with_indifferent_access
which is Rails-only (and controversial)
def initialize(options = {}) | ||
self.components = DEFAULT_COMPONENTS | ||
.merge(options[:components] || ::Inky.configuration.components) | ||
.transform_values { |component_class| component_class.new(self) } |
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.
transform_values
is Ruby 2.4+ only; we support older rubies (I think). Would be easy to require 'backports/2.4.0/hash/transform_values'
or change the code.
@inky = inky | ||
end | ||
|
||
def _pass_through_attributes(elem) |
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.
I'm not sure why these methods started with _
(simili-private?) but if we are to move them we probably should use the standard conventions and remove the leading _
. You can make them protected
if you like, but I don't feel that would be necessary.
No description provided.