Class: Frails::Component::Base
- Defined in:
- lib/frails/component/base.rb
Constant Summary collapse
- PRIVATE_METHODS =
%i[render method_missing locals to_partial_path].freeze
Instance Method Summary collapse
-
#initialize(view, path, options) ⇒ Base
constructor
A new instance of Base.
- #locals ⇒ Object
- #to_partial_path ⇒ Object
Methods inherited from Abstract
after_render, before_render, #method_missing
Constructor Details
#initialize(view, path, options) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 |
# File 'lib/frails/component/base.rb', line 6 def initialize(view, path, ) super @locals = @options.fetch(:locals, @options) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Frails::Component::Abstract
Instance Method Details
#locals ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/frails/component/base.rb', line 12 def locals hash = {} public_methods(false).each do |method| hash[method] = send(method) unless PRIVATE_METHODS.include?(method) end hash.merge @locals end |
#to_partial_path ⇒ Object
20 21 22 |
# File 'lib/frails/component/base.rb', line 20 def to_partial_path "#{@path}/index" end |