Class: AttributedObject::TypeDefaults

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

Overview

TypeDefaults is a option for default_to: - it will set defaults on the given type (integer: 0, boolean: false, string: ” etc)

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ TypeDefaults

Returns a new instance of TypeDefaults.



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/attributed_object.rb', line 23

def initialize(args={})
  @args = {
    string: '',
    boolean: false,
    integer: 0,
    float: 0.0,
    numeric: 0,
    symbol: nil,
    array: [],
    hash: {}
  }.merge(args)
end

Instance Method Details

#fetch(type_info) ⇒ Object



36
37
38
# File 'lib/attributed_object.rb', line 36

def fetch(type_info)
  @args.fetch(type_info, nil)
end