Module: Conversions

Included in:
ActiveOrient::Base
Defined in:
lib/support/conversions.rb

Overview

Rails-specific stuff

Mimics ActiveModell::conversions

Instance Method Summary collapse

Instance Method Details

#to_keyObject

Returns an Array of all key attributes if any is set, regardless if the object is persisted or not. Returns nil if there are no key attributes.



12
13
14
15
# File 'lib/support/conversions.rb', line 12

def to_key
        key = respond_to?(:rid) && rid
       key ? [key] : nil
end

#to_paramObject

Returns a string representing the object’s key suitable for use in URLs,

# or +nil+ if <tt>persisted?</tt> is +false+.


19
20
21
# File 'lib/support/conversions.rb', line 19

def to_param
        (persisted? && key = to_key) ? key.join('-') : nil
end

#to_partial_pathObject

Returns a string identifying the path associated with the object.

# ActionPack uses this to find a suitable partial to represent the object.


26
27
28
# File 'lib/support/conversions.rb', line 26

def to_partial_path
        self.class._to_partial_path
end