Class: S3DataPacker::Sources::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/s3_data_packer/sources/object.rb

Instance Method Summary collapse

Constructor Details

#initialize(object:, each_method: :each, fetch_method: :fetch, name_method: :name) ⇒ Object

Returns a new instance of Object.



5
6
7
8
9
10
# File 'lib/s3_data_packer/sources/object.rb', line 5

def initialize(object:, each_method: :each, fetch_method: :fetch, name_method: :name)
  @object = object
  @each_method = each_method
  @fetch_method = fetch_method
  @name_method = name_method
end

Instance Method Details

#each(&block) ⇒ Object



16
17
18
19
20
# File 'lib/s3_data_packer/sources/object.rb', line 16

def each &block
  @object.send(@each_method) do |item|
    yield item
  end
end

#fetch(item) ⇒ Object



22
23
24
# File 'lib/s3_data_packer/sources/object.rb', line 22

def fetch(item)
  @object.send(@fetch_method, item)
end

#nameObject



12
13
14
# File 'lib/s3_data_packer/sources/object.rb', line 12

def name
  @object.send(@name_method)
end