Class: Rbexy::ComponentProviders::RbexyProvider
- Inherits:
-
Object
- Object
- Rbexy::ComponentProviders::RbexyProvider
- Defined in:
- lib/rbexy/component_providers/rbexy_provider.rb
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#find(name) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/rbexy/component_providers/rbexy_provider.rb', line 13 def find(name) ActiveSupport::Inflector.constantize("#{name}Component") rescue NameError => e raise e unless e. =~ /wrong constant name/ || e. =~ /uninitialized constant/ nil end |
#match?(name) ⇒ Boolean
4 5 6 |
# File 'lib/rbexy/component_providers/rbexy_provider.rb', line 4 def match?(name) name =~ /^[A-Z]/ && find(name) != nil end |
#render(context, name, **attrs, &block) ⇒ Object
8 9 10 11 |
# File 'lib/rbexy/component_providers/rbexy_provider.rb', line 8 def render(context, name, **attrs, &block) props = attrs.transform_keys { |k| ActiveSupport::Inflector.underscore(k.to_s).to_sym } find(name).new(context, **props).render(&block) end |