Class: Frails::Component::PlainComponent

Inherits:
AbstractComponent show all
Defined in:
lib/frails/component/plain_component.rb

Constant Summary collapse

PRIVATE_METHODS =
%i[render method_missing locals].freeze

Instance Method Summary collapse

Methods inherited from AbstractComponent

after_render, before_render, #method_missing

Constructor Details

#initialize(view, options) ⇒ PlainComponent

Returns a new instance of PlainComponent.



6
7
8
9
10
# File 'lib/frails/component/plain_component.rb', line 6

def initialize(view, options)
  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::AbstractComponent

Instance Method Details

#localsObject



12
13
14
15
16
17
18
# File 'lib/frails/component/plain_component.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