Module: SData::PayloadMap::InstanceMethods

Defined in:
lib/s_data/payload_map/payload_map.rb

Instance Method Summary collapse

Instance Method Details

#associations_with_deleted(expand = :all_children) ⇒ Object

Walks the payload, loading each association, descending into children, and yielding the tuple

payload_map_definition, node_object(s)

for each node. Can use without a block

to fire all faults – sync uses this when caching changed objects.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/s_data/payload_map/payload_map.rb', line 67

def associations_with_deleted(expand=:all_children)
  return if expand == :none
  payload_map.each_pair do |child_node_name, child_node_data|
    if child_node_data[:type] == :association
      expand = :none
    elsif child_node_data[:type] == :child
      expand = :all_children
    else
      next
    end
    child = __send__(child_node_data[:method_name_with_deleted])
    yield child_node_data.merge(:name => child_node_name), child if block_given?
    case child
    when Array
      child.each{ |grandchild| grandchild.associations_with_deleted(expand) if child.is_a?(SData::VirtualBase)}
    when SData::VirtualBase
      associations_with_deleted(expand)
    end
  end
end

#payloadObject



59
60
61
# File 'lib/s_data/payload_map/payload_map.rb', line 59

def payload
  self
end