Class: RailsReactComponents::Components::Prop

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_react_components/components/prop.rb

Instance Method Summary collapse

Constructor Details

#initialize(method_name, options) ⇒ Prop

Returns a new instance of Prop.



6
7
8
9
# File 'lib/rails_react_components/components/prop.rb', line 6

def initialize(method_name, options)
  @method_name = method_name.to_sym
  @options = options
end

Instance Method Details

#build(component) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/rails_react_components/components/prop.rb', line 11

def build(component)
  if on.present?
    component.send(on).send(method_name)
  else
    component.send(method_name)
  end
end

#include_blank?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/rails_react_components/components/prop.rb', line 19

def include_blank?
  options.fetch(:include_blank, true)
end

#nameObject



23
24
25
26
27
28
29
30
31
# File 'lib/rails_react_components/components/prop.rb', line 23

def name
  if as.present?
    as
  elsif RailsReactComponents.camelize_props
    method_name.to_s.camelize(:lower).to_sym
  else
    method_name
  end
end