Class: ActiveRecordQuery::ArgumentStacker

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record_query/argument_stacker.rb

Overview

The stacker class receives a class as context to define instance methods ordered to collect a list of data in the class instance

Instance Method Summary collapse

Constructor Details

#initialize(context, stack_name) ⇒ ArgumentStacker

Returns a new instance of ArgumentStacker.



6
7
8
9
# File 'lib/active_record_query/argument_stacker.rb', line 6

def initialize(context, stack_name)
  @context = context
  @stack_name = stack_name
end

Instance Method Details

#add(args) ⇒ Object



11
12
13
14
15
# File 'lib/active_record_query/argument_stacker.rb', line 11

def add(args)
  context.define_method(next_method_name) do
    args
  end
end

#listObject



17
18
19
# File 'lib/active_record_query/argument_stacker.rb', line 17

def list
  stacked_methods.map { |method| context.send(method) }.flatten
end