Class: RemoteResource::AttributeKey

Inherits:
Object
  • Object
show all
Defined in:
lib/remote_resource/attribute_key.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix, named_resource, scope, method) ⇒ AttributeKey

Returns a new instance of AttributeKey.



5
6
7
8
9
10
# File 'lib/remote_resource/attribute_key.rb', line 5

def initialize(prefix, named_resource, scope, method)
  @prefix = prefix
  @named_resource = named_resource
  @scope = scope || {}
  @method = method
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



3
4
5
# File 'lib/remote_resource/attribute_key.rb', line 3

def method
  @method
end

#named_resourceObject (readonly)

Returns the value of attribute named_resource.



3
4
5
# File 'lib/remote_resource/attribute_key.rb', line 3

def named_resource
  @named_resource
end

#prefixObject (readonly)

Returns the value of attribute prefix.



3
4
5
# File 'lib/remote_resource/attribute_key.rb', line 3

def prefix
  @prefix
end

Instance Method Details

#for_attributeObject Also known as: to_s



21
22
23
# File 'lib/remote_resource/attribute_key.rb', line 21

def for_attribute
  [@prefix, scope_string, @named_resource, @method].compact.join('/')
end

#for_resourceObject Also known as: for_storage



16
17
18
# File 'lib/remote_resource/attribute_key.rb', line 16

def for_resource
  [@prefix, scope_string, @named_resource].compact.join('/')
end

#scope_stringObject



12
13
14
# File 'lib/remote_resource/attribute_key.rb', line 12

def scope_string
  @scope.map { |k, v| "#{k}=#{v}" }.join('&')
end