Class: Lytix::MethodList

Inherits:
Object
  • Object
show all
Defined in:
lib/lytix/method_list.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args) ⇒ Object



15
16
17
# File 'lib/lytix/method_list.rb', line 15

def method_missing(symbol, *args)
  list << [symbol, args]
end

Instance Method Details

#listObject



3
4
5
# File 'lib/lytix/method_list.rb', line 3

def list
  @list ||= []
end

#snippet(tracker_name) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/lytix/method_list.rb', line 7

def snippet(tracker_name)
  list.map do |method, args|
    method_name = method.to_s.camelize(:lower)
    formatted_args = args.map{|a| format_argument(a) }.join(', ')
    "#{tracker_name}.#{method_name}(#{formatted_args});"
  end.join(' ')
end