create_callback()
click to toggle source
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
def instance_from_db
instance.class.get(instance.id)
end
is_blank?(object)
click to toggle source
def is_blank?(object)
object.nil? || object == '' || object == []
end
is_new?(object)
click to toggle source
def is_new?(object)
object.new?
end
is_present?(object)
click to toggle source
def is_present?(object)
!is_blank? object
end
klass_previous_instances(&block)
click to toggle source
def klass_previous_instances(&block)
klass.all(:conditions => {settings.url_attribute => [nil]}).each(&block)
end
primary_key()
click to toggle source
def primary_key
instance.class.key.first.instance_variable_get '@name'
end
read_attribute(instance, attribute)
click to toggle source
def read_attribute(instance, attribute)
instance.attributes[attribute]
end
url_owners()
click to toggle source
def url_owners
@url_owners ||= url_owners_class.all(:conditions => url_owner_conditions)
end
write_attribute(instance, name, value)
click to toggle source
def write_attribute(instance, name, value)
instance.attribute_set name, value
end