Module: Glamazon::Base

Includes:
Attributes, JSON
Defined in:
lib/glamazon/base.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Methods included from JSON

#encoder, #to_json

Methods included from Attributes

#[], #[]=, #attributes, #method_missing, #read_attribute, #to_s, #write_attribute

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glamazon::Attributes

Class Method Details

.included(base) ⇒ Object



34
35
36
37
38
# File 'lib/glamazon/base.rb', line 34

def self.included(base)
  base.extend ClassMethods
  base.extend Glamazon::Accessors
  base.extend Glamazon::Finder
end

Instance Method Details

#initialize(attributes = {}) ⇒ Object



6
7
8
9
# File 'lib/glamazon/base.rb', line 6

def initialize(attributes = {})
  self.id = SecureRandom.uuid
  attributes.each { |k,v| send "#{k}=", v }
end

#saveObject



11
12
13
# File 'lib/glamazon/base.rb', line 11

def save
  self.class.all << self
end

#touchObject



15
16
17
# File 'lib/glamazon/base.rb', line 15

def touch
  self[:updated_at] = Time.now.getutc
end