Class: Frails::Component::Abstract
- Inherits:
-
Object
- Object
- Frails::Component::Abstract
- Includes:
- ActiveSupport::Callbacks
- Defined in:
- lib/frails/component/abstract.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(view, path, options) ⇒ Abstract
constructor
A new instance of Abstract.
-
#method_missing(method, *args, &block) ⇒ Object
rubocop:disable Lint/ShadowedException, Style/MissingRespondToMissing.
Constructor Details
#initialize(view, path, options) ⇒ Abstract
Returns a new instance of Abstract.
8 9 10 11 12 13 14 |
# File 'lib/frails/component/abstract.rb', line 8 def initialize(view, path, ) @view = view @path = path @options = 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
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/frails/component/abstract.rb', line 27 def method_missing(method, *args, &block) super rescue NoMethodError, NameError => e # the error is not mine, so just releases it as is. raise e if e.name != method begin @view.send method, *args, &block rescue NoMethodError => e raise e if e.name != method raise NoMethodError.new("undefined method `#{method}' for either #{self} or #{@view}", method) rescue NameError => e raise e if e.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
21 22 23 |
# File 'lib/frails/component/abstract.rb', line 21 def after_render(*methods, &block) set_callback :render, :after, *methods, &block end |
.before_render(*methods, &block) ⇒ Object
17 18 19 |
# File 'lib/frails/component/abstract.rb', line 17 def before_render(*methods, &block) set_callback :render, :before, *methods, &block end |