Class: Peddler::Operation Private
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Peddler::Operation
- Defined in:
- lib/peddler/operation.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#initialize(action) ⇒ Operation
constructor
private
A new instance of Operation.
- #store(key, val) ⇒ Object private
- #structure!(*list_keys) ⇒ Object private
- #update(hsh) ⇒ Object (also: #add) private
Constructor Details
#initialize(action) ⇒ Operation
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Operation.
8 9 10 |
# File 'lib/peddler/operation.rb', line 8 def initialize(action) super('Action' => action) end |
Instance Method Details
#store(key, val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/peddler/operation.rb', line 24 def store(key, val) key = camelize(key) if key.is_a?(Symbol) if val.respond_to?(:iso8601) val = val.iso8601 elsif val.is_a?(Struct) val = val.to_h end if val.is_a?(Hash) val.each do |subkey, subval| subkey = camelize(subkey) if subkey.is_a?(Symbol) store([key, subkey].join('.'), subval) end else __getobj__.store(key, val) end end |
#structure!(*list_keys) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/peddler/operation.rb', line 12 def structure!(*list_keys) list_key = list_keys.first if has_key?(list_key) builder = StructuredList.new(*list_keys) vals = delete(list_key) update(builder.build(vals)) end self end |
#update(hsh) ⇒ Object Also known as: add
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 47 |
# File 'lib/peddler/operation.rb', line 44 def update(hsh) hsh.each { |key, val| store(key, val) } self end |