module FmRest::Spyke::Model::RecordID
Modifies Spyke
models to use `__record_id` instead of `id` as the “primary key” method, so that we can map a model class to a FM layout with a field named `id` without clobbering it.
The `id` reader method still maps to the record ID for backwards compatibility and because Spyke
hardcodes its use at various points through its codebase, but it can be safely overwritten (e.g. to map to a FM field).
The recommended way to deal with a layout that maps an `id` attribute is to remap it in the model to something else, e.g. `unique_id`.
Public Instance Methods
Sets the modId and converts it to integer if it's not nil
@param value [String, Integer, nil] The new modId
@return [Integer] the record's modId
# File lib/fmrest/spyke/model/record_id.rb, line 53 def __mod_id=(value) @__mod_id = value.nil? ? nil : value.to_i end
Sets the recordId and converts it to integer if it's not nil
@param value [String, Integer, nil] The new recordId
@return [Integer] the record's recordId
# File lib/fmrest/spyke/model/record_id.rb, line 44 def __record_id=(value) @__record_id = value.nil? ? nil : value.to_i end
# File lib/fmrest/spyke/model/record_id.rb, line 57 def __record_id? __record_id.present? end
Spyke
override – Use `__record_id` instead of `id`
@param id [Integer] The id of the record to destroy
# File lib/fmrest/spyke/model/record_id.rb, line 82 def destroy(id = nil) new(__record_id: id).destroy end
Spyke
override – Use `__record_id` instead of `id`
# File lib/fmrest/spyke/model/record_id.rb, line 65 def hash __record_id.hash end
Spyke
override – Renders class string with layout name and `record_id`.
@return [String] A string representation of the class
# File lib/fmrest/spyke/model/record_id.rb, line 74 def inspect "#<#{self.class}(layout: #{self.class.layout}) record_id: #{__record_id.inspect} #{inspect_attributes}>" end
Private Instance Methods
Spyke
override (private)
# File lib/fmrest/spyke/model/record_id.rb, line 90 def conflicting_ids?(attributes) false end