# File lib/stringex/acts_as_url/adapter/data_mapper.rb, line 39 def primary_key instance.class.key.first.instance_variable_get '@name' end
class Stringex::ActsAsUrl::Adapter::DataMapper
Public Class Methods
load()
click to toggle source
# File lib/stringex/acts_as_url/adapter/data_mapper.rb, line 5 def self.load ensure_loadable orm_class.send :include, Stringex::ActsAsUrl::ActsAsUrlInstanceMethods ::DataMapper::Model.send :include, Stringex::ActsAsUrl::ActsAsUrlClassMethods end
Private Class Methods
orm_class()
click to toggle source
# File lib/stringex/acts_as_url/adapter/data_mapper.rb, line 59 def self.orm_class ::DataMapper::Resource end
Private Instance Methods
create_callback()
click to toggle source
# File lib/stringex/acts_as_url/adapter/data_mapper.rb, line 13 def create_callback klass.class_eval do before acts_as_url_configuration.settings.sync_url ? :save : :create, :ensure_unique_url end end
instance_from_db()
click to toggle source
# File lib/stringex/acts_as_url/adapter/data_mapper.rb, line 19 def instance_from_db instance.class.get(instance.id) end
is_blank?(object)
click to toggle source
# File lib/stringex/acts_as_url/adapter/data_mapper.rb, line 23 def is_blank?(object) object.nil? || object == '' || object == [] end
is_new?(object)
click to toggle source
# File lib/stringex/acts_as_url/adapter/data_mapper.rb, line 27 def is_new?(object) object.new? end
is_present?(object)
click to toggle source
# File lib/stringex/acts_as_url/adapter/data_mapper.rb, line 31 def is_present?(object) !is_blank? object end
klass_previous_instances(&block)
click to toggle source
# File lib/stringex/acts_as_url/adapter/data_mapper.rb, line 35 def klass_previous_instances(&block) klass.all(:conditions => {settings.url_attribute => [nil]}).each(&block) end
primary_key()
click to toggle source
read_attribute(instance, attribute)
click to toggle source
# File lib/stringex/acts_as_url/adapter/data_mapper.rb, line 43 def read_attribute(instance, attribute) instance.attributes[attribute] end
url_owners()
click to toggle source
# File lib/stringex/acts_as_url/adapter/data_mapper.rb, line 47 def url_owners @url_owners ||= url_owners_class.all(:conditions => url_owner_conditions) end
write_attribute(instance, name, value)
click to toggle source
# File lib/stringex/acts_as_url/adapter/data_mapper.rb, line 55 def write_attribute(instance, name, value) instance.attribute_set name, value end