Module: LLT::Helpers::Initialize

Defined in:
lib/llt/helpers/initialize.rb

Instance Method Summary collapse

Instance Method Details

#extract_args!(args, keys = init_keys) ⇒ Object

Maps Hash keys to instance_variables

Recommended usage is to implement #init_keys as an Array of Symbols Example: def init_keys

%i{ type stem inflection_class }

end

This will set @type, @stem and @inflection_class with their corresponding values. Keys not defined in init_keys or as param are untouched.



16
17
18
19
20
# File 'lib/llt/helpers/initialize.rb', line 16

def extract_args!(args, keys = init_keys)
  keys.each do |var_name|
    instance_variable_set("@#{var_name}", args[var_name])
  end
end

#extract_normalized_args!(args, keys = init_keys) ⇒ Object



22
23
24
25
# File 'lib/llt/helpers/initialize.rb', line 22

def extract_normalized_args!(args, keys = init_keys)
  args = Helpers::Normalizer.normalize_args(args)
  extract_args!(args, keys)
end