Class: SQB::WhereDSL
- Inherits:
-
Object
- Object
- SQB::WhereDSL
- Defined in:
- lib/sqb/where_dsl.rb
Defined Under Namespace
Classes: Attribute, NegativeAttribute, PositiveAttribute
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Instance Method Summary collapse
-
#initialize ⇒ WhereDSL
constructor
A new instance of WhereDSL.
- #method_missing(name, value = nil) ⇒ Object
Constructor Details
#initialize ⇒ WhereDSL
Returns a new instance of WhereDSL.
6 7 8 |
# File 'lib/sqb/where_dsl.rb', line 6 def initialize @hash = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, value = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sqb/where_dsl.rb', line 10 def method_missing(name, value = nil) if name =~ /(.*)\=\z/ attribute_name = $1 @hash[attribute_name.to_sym] ||= {} @hash[attribute_name.to_sym][:equal] = value else @hash[name.to_sym] ||= {} attribute = PositiveAttribute.new(name.to_sym, @hash) end end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
4 5 6 |
# File 'lib/sqb/where_dsl.rb', line 4 def hash @hash end |