Class: Frails::Component::AbstractComponent
- Inherits:
-
Object
- Object
- Frails::Component::AbstractComponent
- Includes:
- ActiveSupport::Callbacks
- Defined in:
- lib/frails/component/abstract_component.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(view, options) ⇒ AbstractComponent
constructor
A new instance of AbstractComponent.
-
#method_missing(method, *args, &block) ⇒ Object
rubocop:disable Lint/ShadowedException, Style/MissingRespondToMissing.
Constructor Details
#initialize(view, options) ⇒ AbstractComponent
Returns a new instance of AbstractComponent.
8 9 10 11 12 |
# File 'lib/frails/component/abstract_component.rb', line 8 def initialize(view, ) @view, @options = view, end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
rubocop:disable Lint/ShadowedException, Style/MissingRespondToMissing
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/frails/component/abstract_component.rb', line 25 def method_missing(method, *args, &block) super rescue NoMethodError, NameError => e1 # the error is not mine, so just releases it as is. raise e1 if e1.name != method begin @view.send method, *args, &block rescue NoMethodError => e2 raise e2 if e2.name != method raise NoMethodError.new("undefined method `#{method}' for either #{self} or #{@view}", method) rescue NameError => e2 raise e2 if e2.name != method raise NameError.new("undefined local variable `#{method}' for either #{self} or #{@view}", method) end end |
Class Method Details
.after_render(*methods, &block) ⇒ Object
19 20 21 |
# File 'lib/frails/component/abstract_component.rb', line 19 def after_render(*methods, &block) set_callback :render, :after, *methods, &block end |
.before_render(*methods, &block) ⇒ Object
15 16 17 |
# File 'lib/frails/component/abstract_component.rb', line 15 def before_render(*methods, &block) set_callback :render, :before, *methods, &block end |