Module: Neo4j::Rails::Timestamps::ClassMethods

Defined in:
lib/neo4j/rails/timestamps.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) define_timestamp_method(method_name, property)



64
65
66
67
68
69
70
# File 'lib/neo4j/rails/timestamps.rb', line 64

def define_timestamp_method(method_name, property)
  class_eval <<-RUBY, __FILE__, __LINE__
						def #{method_name}
							write_date_or_timestamp(:#{property}) if Neo4j::Config[:timestamps]
						end
  RUBY
end

- (Object) property_setup(property, options)



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/neo4j/rails/timestamps.rb', line 51

def property_setup(property, options)
  super
  define_timestamp_method(:create_timestamp, :created_at) if property == :created_at
  define_timestamp_method(:update_timestamp, :updated_at) if property == :updated_at
  # ensure there's always a type on the timestamp properties
  if Neo4j::Config[:timestamps] && TIMESTAMP_PROPERTIES.include?(property)
    if _decl_props[property][:converter] == Neo4j::TypeConverters::DefaultConverter
      _decl_props[property][:type] = Time
      _decl_props[property][:converter] = Neo4j::TypeConverters.converter(Time)
    end
  end
end