Module: ObjectJSONMapper::Conversion

Included in:
Base
Defined in:
lib/object_json_mapper/conversion.rb

Instance Method Summary collapse

Instance Method Details

#to_keyArray

Returns all key attributes.

Returns:

  • (Array)

    all key attributes



8
9
10
11
12
# File 'lib/object_json_mapper/conversion.rb', line 8

def to_key
  [].tap do |a|
    a << id if respond_to?(:id)
  end
end

#to_modelObject



3
4
5
# File 'lib/object_json_mapper/conversion.rb', line 3

def to_model
  self
end

#to_paramString

Returns object’s key suitable for use in URLs.

Returns:

  • (String)

    object’s key suitable for use in URLs



15
16
17
# File 'lib/object_json_mapper/conversion.rb', line 15

def to_param
  id.to_s
end

#to_partial_pathObject



19
20
21
22
# File 'lib/object_json_mapper/conversion.rb', line 19

def to_partial_path
  name = self.class.name.underscore
  [name.pluralize, name].join('/')
end