Module: YFantasy::Subresourceable::InstanceMethods

Defined in:
lib/y_fantasy/concerns/subresourceable.rb

Instance Method Summary collapse

Instance Method Details

#add_fetched_subresources(subresources = []) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/y_fantasy/concerns/subresourceable.rb', line 15

def add_fetched_subresources(subresources = [])
  # Using wrap_in_array here because Array() will convert a hash to array
  Transformations::T.wrap_in_array(subresources).each do |subresource|
    case subresource
    when Symbol
      fetched_subresources << subresource
    when Hash
      key = subresource.keys.first
      fetched_subresources << key
      sub_instances = Transformations::T.wrap_in_array(send(key))
      sub_instances&.each do |sub_instance|
        sub_instance.add_fetched_subresources(subresource[key])
      end
    end
  end
end

#fetched_subresourcesObject



11
12
13
# File 'lib/y_fantasy/concerns/subresourceable.rb', line 11

def fetched_subresources
  @fetched_subresources ||= Set.new
end