Module: VCDry::DSL

Extended by:
ActiveSupport::Concern
Includes:
Core
Defined in:
lib/vcdry/dsl.rb

Instance Method Summary collapse

Methods included from Core

#vcdry_parse_keywords

Instance Method Details

#initialize(**kwargs) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/vcdry/dsl.rb', line 18

def initialize(**kwargs)
  run_callbacks :initialize do
    unknown_kwargs = vcdry_parse_keywords(kwargs)
    vcdry_parse_unknown_keywords(unknown_kwargs)
    super
  end
end

#vcdry_parse_unknown_keywords(unknown_kwargs = {}) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/vcdry/dsl.rb', line 26

def vcdry_parse_unknown_keywords(unknown_kwargs = {})
  raise UnknownArgumentError.new(*unknown_kwargs.keys) if self.class.vcdry.strict? && unknown_kwargs.present?
  return unless self.class.vcdry.gather_unknown_keywords?

  config = self.class.vcdry.other_keywords_config
  instance_variable_set(config.instance_variable, config.type_cast(unknown_kwargs))
end