Module: Hypem::Helper

Included in:
Blog, Track, User
Defined in:
lib/hypem/helper.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/hypem/helper.rb', line 4

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#update_from_response(raw_hash) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/hypem/helper.rb', line 8

def update_from_response(raw_hash)
  raw_hash.each_pair do |key,value|
    key = key.to_sym
    new_key = self.class.key_conversions[key]
    key = new_key unless new_key.nil?

    if self.class.datetime_conversions.andand.include? key
      value = Time.at(value).to_datetime 
    end

    instance_variable_set("@#{key}",value)

    self.class.class_eval { attr_reader key }
  end
end