Module: Pinky::Model

Defined in:
lib/pinky/model.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cached_atObject (readonly)

Returns the value of attribute cached_at.



9
10
11
# File 'lib/pinky/model.rb', line 9

def cached_at
  @cached_at
end

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
# File 'lib/pinky/model.rb', line 3

def self.included base
  base.extend HasCaches unless base.is_a?(HasCaches)
  base.extend ModelFetchMethods unless base.is_a?(ModelFetchMethods)
  base.extend ClassMethods
end

Instance Method Details

#initialize(hash) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/pinky/model.rb', line 11

def initialize hash
  @hash = hash
  hash.keys.each do |method|
    define_singleton_method method do
      @hash[method]
    end
  end
  @cached_at = DateTime.now
end