Class: ViewComponentProps::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/view_component_props/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



26
27
28
29
30
# File 'lib/view_component_props/configuration.rb', line 26

def initialize
  @auto_include = true
  @reject_undefined_props = false
  @custom_casters = HashWithIndifferentAccess.new
end

Instance Attribute Details

#auto_includeObject

Returns the value of attribute auto_include.



22
23
24
# File 'lib/view_component_props/configuration.rb', line 22

def auto_include
  @auto_include
end

#custom_castersObject (readonly)

Returns the value of attribute custom_casters.



24
25
26
# File 'lib/view_component_props/configuration.rb', line 24

def custom_casters
  @custom_casters
end

#reject_undefined_propsObject

Returns the value of attribute reject_undefined_props.



23
24
25
# File 'lib/view_component_props/configuration.rb', line 23

def reject_undefined_props
  @reject_undefined_props
end

Instance Method Details

#register_caster(key, &block) ⇒ Object

Raises:

  • (ArgumentError)


32
33
34
35
36
37
# File 'lib/view_component_props/configuration.rb', line 32

def register_caster(key, &block)
  raise ArgumentError, "register_caster requires a block" unless block

  custom_casters[key] = block
  Casters.registry[key] = block if defined?(Casters)
end