Class: Hold::Sequel::PropertyMapper::CreatedAt

Inherits:
Column show all
Defined in:
lib/hold/sequel/property_mapper/created_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, #post_update, #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



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

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

#build_update_row(entity, table, row) ⇒ Object



7
8
# File 'lib/hold/sequel/property_mapper/created_at.rb', line 7

def build_update_row(entity, table, row)
end

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



10
11
12
# File 'lib/hold/sequel/property_mapper/created_at.rb', line 10

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