class RemoteRecord::Type
RemoteRecord
uses the Active Record Types system to serialize to and from a remote resource.
Public Class Methods
[](config_override)
click to toggle source
# File lib/remote_record/type.rb, line 33 def self.[](config_override) Class.new(self).tap { |configured_type| configured_type.config = config_override } end
for(remote_record_class)
click to toggle source
# File lib/remote_record/type.rb, line 30 def self.for(remote_record_class) Class.new(self) do |type| type.parent = remote_record_class def self.[](config_override) Class.new(self).tap { |configured_type| configured_type.config = config_override } end def cast(remote_resource_id) return remote_resource_id if remote_resource_id.is_a?(parent) parent.new(remote_resource_id, config) end end end
Public Instance Methods
cast(_remote_resource_id)
click to toggle source
# File lib/remote_record/type.rb, line 16 def cast(_remote_resource_id) raise 'cast not defined' end
deserialize(value)
click to toggle source
# File lib/remote_record/type.rb, line 20 def deserialize(value) cast(value) end
serialize(representation)
click to toggle source
# File lib/remote_record/type.rb, line 24 def serialize(representation) return representation.remote_resource_id if representation.respond_to? :remote_resource_id representation.to_s end
type()
click to toggle source
# File lib/remote_record/type.rb, line 12 def type :string end