Module: Remotable::Adapters::ActiveResource

Extended by:
ActiveSupport::Concern
Defined in:
lib/remotable/adapters/active_resource.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#remote_key_pathObject

If we use ‘remote_key` to explicitly set the path where this resource ought to be found, then we should use the same path when updating or destroying this resource.

To accomplish this, we need to override ActiveResource’s element_path to return the canonical path for this resource.



34
35
36
# File 'lib/remotable/adapters/active_resource.rb', line 34

def remote_key_path
  @remote_key_path
end

Instance Method Details

#[](attribute) ⇒ Object



17
18
19
# File 'lib/remotable/adapters/active_resource.rb', line 17

def [](attribute)
  attributes[attribute.to_s]
end

#[]=(attribute, value) ⇒ Object



21
22
23
# File 'lib/remotable/adapters/active_resource.rb', line 21

def []=(attribute, value)
  attributes[attribute.to_s] = value
end

#element_path(*args) ⇒ Object



36
37
38
39
# File 'lib/remotable/adapters/active_resource.rb', line 36

def element_path(*args)
  return remote_key_path if remote_key_path
  super
end

#key?(attribute) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/remotable/adapters/active_resource.rb', line 13

def key?(attribute)
  attributes.key?(attribute.to_s)
end