Module: ViewComponentProps

Defined in:
lib/view_component_props.rb,
lib/view_component_props/errors.rb,
lib/view_component_props/casters.rb,
lib/view_component_props/railtie.rb,
lib/view_component_props/version.rb,
lib/view_component_props/definable.rb,
lib/view_component_props/definition.rb,
lib/view_component_props/casters/base.rb,
lib/view_component_props/configuration.rb

Defined Under Namespace

Modules: Casters, Definable Classes: CastError, Configuration, Definition, Error, InvalidEnumValueError, Railtie, RequiredPropError, UnknownCastError, UnknownOptionError, UnknownPropsError, ValidationFailedError

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.configurationObject



7
8
9
# File 'lib/view_component_props/configuration.rb', line 7

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



11
12
13
# File 'lib/view_component_props/configuration.rb', line 11

def configure
  yield(configuration)
end

.install!(target = ViewComponent::Base) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/view_component_props.rb', line 16

def install!(target = ViewComponent::Base)
  return if target.include?(Definable)

  target.include(Definable)
  target.class_eval do
    def initialize(props = {})
      super()
      setup_props_for(props)
      after_initialize
    end
  end
end

.reset_configuration!Object



15
16
17
18
# File 'lib/view_component_props/configuration.rb', line 15

def reset_configuration!
  @configuration = Configuration.new
  Casters.reset! if defined?(Casters)
end