Class: BatchAgg::AttrMagic

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

Instance Method Summary collapse

Constructor Details

#initialize(model, outer_table) ⇒ AttrMagic

Returns a new instance of AttrMagic.



59
60
61
62
# File 'lib/batchagg.rb', line 59

def initialize(model, outer_table)
  @model = model
  @outer_table = outer_table
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/batchagg.rb', line 64

def method_missing(name, *args, &)
  if @model.columns_hash.key?(name.to_s)
    @outer_table[name]
  else
    super
  end
end

Instance Method Details

#respond_to_missing?(name) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/batchagg.rb', line 72

def respond_to_missing?(name, *)
  @model.columns_hash.key?(name.to_s) || super
end