Class: Protobuf::ActiveRecord::Serialization::ClassMethods::DateCaller
- Inherits:
-
Object
- Object
- Protobuf::ActiveRecord::Serialization::ClassMethods::DateCaller
- Defined in:
- lib/protobuf/active_record/serialization.rb
Instance Method Summary collapse
- #call(selph) ⇒ Object
-
#initialize(field) ⇒ DateCaller
constructor
A new instance of DateCaller.
Constructor Details
#initialize(field) ⇒ DateCaller
154 155 156 |
# File 'lib/protobuf/active_record/serialization.rb', line 154 def initialize(field) @field = field end |
Instance Method Details
#call(selph) ⇒ Object
158 159 160 161 162 163 164 165 166 |
# File 'lib/protobuf/active_record/serialization.rb', line 158 def call(selph) value = selph.__send__(@field) if value value.to_time(:utc).to_i end rescue NameError # Has happened when field is not on model or ignored from db nil end |