Module: Modis::Attribute

Defined in:
lib/modis/attribute.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

TYPES =
{ string: [String],
integer: [0.class],
float: [Float],
timestamp: [Time],
hash: [Hash],
array: [Array],
boolean: [TrueClass, FalseClass] }.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



13
14
15
16
17
18
# File 'lib/modis/attribute.rb', line 13

def self.included(base)
  base.extend ClassMethods
  base.instance_eval do
    bootstrap_attributes
  end
end

Instance Method Details

#assign_attributes(hash) ⇒ Object



78
79
80
81
82
83
# File 'lib/modis/attribute.rb', line 78

def assign_attributes(hash)
  hash.each do |k, v|
    setter = "#{k}="
    send(setter, v) if respond_to?(setter)
  end
end

#attributesObject



74
75
76
# File 'lib/modis/attribute.rb', line 74

def attributes
  @modis_attributes
end

#read_attribute(key) ⇒ Object



89
90
91
# File 'lib/modis/attribute.rb', line 89

def read_attribute(key)
  attributes[key.to_s]
end

#write_attribute(key, value) ⇒ Object



85
86
87
# File 'lib/modis/attribute.rb', line 85

def write_attribute(key, value)
  attributes[key.to_s] = value
end