Class: Peddler::Operation Private

Inherits:
SimpleDelegator
  • Object
show all
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.

Constant Summary collapse

CAPITAL_LETTERS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/[A-Z]/

Instance Method Summary collapse

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.



10
11
12
# File 'lib/peddler/operation.rb', line 10

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.



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/peddler/operation.rb', line 26

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.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/peddler/operation.rb', line 14

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.



40
41
42
43
# File 'lib/peddler/operation.rb', line 40

def update(hsh)
  hsh.each { |key, val| store(key, val) }
  self
end