Module: Flex::ActiveModel::Timestamps

Defined in:
lib/flex/active_model/timestamps.rb

Instance Method Summary collapse

Instance Method Details

#attribute_created_at(props = {}) ⇒ Object



10
11
12
13
# File 'lib/flex/active_model/timestamps.rb', line 10

def attribute_created_at(props={})
  attribute :created_at, {:type => DateTime}.merge(props)
  before_create { self.created_at = Time.now.utc }
end

#attribute_timestamps(props = {}) ⇒ Object



5
6
7
8
# File 'lib/flex/active_model/timestamps.rb', line 5

def attribute_timestamps(props={})
  attribute_created_at props
  attribute_updated_at props
end

#attribute_updated_at(props = {}) ⇒ Object



15
16
17
18
# File 'lib/flex/active_model/timestamps.rb', line 15

def attribute_updated_at(props={})
  attribute :updated_at, {:type => DateTime}.merge(props)
  before_save { self.updated_at = Time.now.utc }
end