Module: Setsumei::Build

Defined in:
lib/setsumei/build.rb,
lib/setsumei/build/key.rb

Defined Under Namespace

Classes: Key

Class Method Summary collapse

Class Method Details

.a(klass, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/setsumei/build.rb', line 5

def Build.a(klass,options = {})
  inform_developer "wrong number of arguments, options must include { from: data }" unless options.keys.include? :from
  detect_string(klass) and return(options[:from].to_s)
  detect_float(klass) and return(options[:from].to_f)
  inform_developer "#{klass} should be able to list its attributes" unless klass.respond_to? :defined_attributes

  klass.new.tap do |object|
    klass.defined_attributes.each do |_,attribute|
      attribute.set_value_on object, from_value_in: options[:from]
    end
  end
end