Module: DataMapper::Resource

Defined in:
lib/rails_dm_datastore/data_mapper.rb

Instance Method Summary collapse

Instance Method Details

#attributes=(attributes) ⇒ Object

make sure that all properties of the model that have to do with date or time are converted run through the fix_date converter



14
15
16
17
18
19
20
21
22
23
# File 'lib/rails_dm_datastore/data_mapper.rb', line 14

def attributes=(attributes)
  return if attributes.nil?
  self.class.properties.each do |t|
    if !(t.name.to_s =~ /.*_at/) && (t.type.to_s =~ /Date|Time/ ) &&
        attributes.include?("#{t.name.to_s}(1i)")
      MultiparameterAssignments.fix_date(attributes, t.name.to_s, t.type)
    end
  end
  self.attributes_orig=(attributes)
end

#attributes_orig=Object



4
# File 'lib/rails_dm_datastore/data_mapper.rb', line 4

alias :attributes_orig= :attributes=

#new_record?Boolean

silence deprecation warnings

Returns:

  • (Boolean)


8
# File 'lib/rails_dm_datastore/data_mapper.rb', line 8

def new_record?; new?; end

#to_paramObject

avoid object references in URLs



6
# File 'lib/rails_dm_datastore/data_mapper.rb', line 6

def to_param; id.id.to_s; end

#update_attributes(*args) ⇒ Object

avoid NoMethodError



10
# File 'lib/rails_dm_datastore/data_mapper.rb', line 10

def update_attributes(*args); update(*args); end