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, parent: '') ⇒ 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, parent: '') ⇒ 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 |
# File 'lib/peddler/operation.rb', line 24 def store(key, val, parent: '') key = camelize(key) if key.is_a?(Symbol) key = "#{parent}.#{key}" unless parent.empty? val = val.iso8601 if val.respond_to?(:iso8601) val = val.to_h if val.is_a?(Struct) if val.is_a?(Hash) val.each { |keyval| store(*keyval, parent: key) } 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.shift found_key = keys.find { |key| key.end_with?(list_key) } if found_key builder = StructuredList.new(found_key, *list_keys) vals = delete(found_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.
38 39 40 41 |
# File 'lib/peddler/operation.rb', line 38 def update(hsh) hsh.each { |key, val| store(key, val) } self end |