Add an ability to create custom components#102
Add an ability to create custom components#102maximgladkov wants to merge 3 commits intofoundation:developfrom
Conversation
marcandre
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.