Class: Hold::Sequel::PropertyMapper::UpdatedAt

Inherits:
Column show all
Defined in:
lib/hold/sequel/property_mapper/updated_at.rb

Instance Attribute Summary

Attributes inherited from Column

#column_alias, #column_name, #column_qualified, #columns_aliases_and_tables_for_select, #table

Attributes inherited from Hold::Sequel::PropertyMapper

#property, #property_name, #repository

Instance Method Summary collapse

Methods inherited from Column

#initialize, #load_value, #make_filter, #make_multi_filter

Methods inherited from Hold::Sequel::PropertyMapper

#columns_aliases_and_tables_for_select, #initialize, #load_value, #load_values, #make_filter, #make_multi_filter, #post_delete, #pre_delete, #pre_insert, #pre_update, setter_dependencies_for

Constructor Details

This class inherits a constructor from Hold::Sequel::PropertyMapper::Column

Instance Method Details

#build_insert_row(entity, table, row, id = nil) ⇒ Object Also known as: build_update_row



3
4
5
# File 'lib/hold/sequel/property_mapper/updated_at.rb', line 3

def build_insert_row(entity, table, row, id=nil)
  row[@column_name] = Time.now if table == @table
end

#post_insert(entity, rows, last_insert_id = nil) ⇒ Object



9
10
11
# File 'lib/hold/sequel/property_mapper/updated_at.rb', line 9

def post_insert(entity, rows, last_insert_id=nil)
  entity[@property_name] = rows[@table][@column_name]
end

#post_update(id, update_entity, rows, from_pre_update) ⇒ Object



13
14
15
# File 'lib/hold/sequel/property_mapper/updated_at.rb', line 13

def post_update(id, update_entity, rows, from_pre_update)
  update_entity[@property_name] = rows[@table][@column_name]
end