Class: BabySqueel::Nodes::Attribute

Inherits:
Generic
  • Object
show all
Defined in:
lib/baby_squeel/nodes.rb

Instance Method Summary collapse

Methods included from Operators::ArelAliasing

#arel_alias

Methods included from Operators::Generic

#op

Methods inherited from Proxy

const_missing, #respond_to?

Constructor Details

#initialize(parent, name) ⇒ Attribute

Returns a new instance of Attribute.



73
74
75
76
77
# File 'lib/baby_squeel/nodes.rb', line 73

def initialize(parent, name)
  @parent = parent
  @name = name
  super(parent._table[name])
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BabySqueel::Nodes::Proxy

Instance Method Details

#_arelObject



87
88
89
90
91
92
93
94
95
# File 'lib/baby_squeel/nodes.rb', line 87

def _arel
  parent_arel = @parent._arel

  if parent_arel && parent_arel.last
    parent_arel.last.left[@name]
  else
    super
  end
end

#in(rel) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/baby_squeel/nodes.rb', line 79

def in(rel)
  if rel.is_a? ::ActiveRecord::Relation
    ::Arel::Nodes::In.new(self, Arel.sql(rel.to_sql))
  else
    super
  end
end