Class: RemoteResource::AttributeKey
- Inherits:
-
Object
- Object
- RemoteResource::AttributeKey
- Defined in:
- lib/remote_resource/attribute_key.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#named_resource ⇒ Object
readonly
Returns the value of attribute named_resource.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Instance Method Summary collapse
- #for_attribute ⇒ Object (also: #to_s)
- #for_resource ⇒ Object (also: #for_storage)
-
#initialize(prefix, named_resource, scope, method) ⇒ AttributeKey
constructor
A new instance of AttributeKey.
- #scope_string ⇒ Object
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
#method ⇒ Object (readonly)
Returns the value of attribute method.
3 4 5 |
# File 'lib/remote_resource/attribute_key.rb', line 3 def method @method end |
#named_resource ⇒ Object (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 |
#prefix ⇒ Object (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_attribute ⇒ Object 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_resource ⇒ Object 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_string ⇒ Object
12 13 14 |
# File 'lib/remote_resource/attribute_key.rb', line 12 def scope_string @scope.map { |k, v| "#{k}=#{v}" }.join('&') end |