Class: Airrel::WhereClause
- Inherits:
-
Object
- Object
- Airrel::WhereClause
- Defined in:
- lib/airrel/where_clause.rb
Instance Attribute Summary collapse
-
#predicates ⇒ Object
readonly
Returns the value of attribute predicates.
Instance Method Summary collapse
- #any? ⇒ Boolean
-
#initialize(predicates = []) ⇒ WhereClause
constructor
A new instance of WhereClause.
- #inspect ⇒ Object
- #merge(conditions) ⇒ Object
- #to_airtable_formula ⇒ Object
Constructor Details
#initialize(predicates = []) ⇒ WhereClause
Returns a new instance of WhereClause.
7 8 9 |
# File 'lib/airrel/where_clause.rb', line 7 def initialize(predicates = []) @predicates = predicates end |
Instance Attribute Details
#predicates ⇒ Object (readonly)
Returns the value of attribute predicates.
5 6 7 |
# File 'lib/airrel/where_clause.rb', line 5 def predicates @predicates end |
Instance Method Details
#any? ⇒ Boolean
26 |
# File 'lib/airrel/where_clause.rb', line 26 def any? = @predicates.any? |
#inspect ⇒ Object
35 |
# File 'lib/airrel/where_clause.rb', line 35 def inspect = @predicates.inspect |
#merge(conditions) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/airrel/where_clause.rb', line 11 def merge(conditions) new_predicates = case conditions when Hash [FormulaBuilder.hash_to_formula(conditions)] when String [conditions] when Array conditions else [conditions.to_s] end WhereClause.new(@predicates + new_predicates) end |
#to_airtable_formula ⇒ Object
28 29 30 31 32 33 |
# File 'lib/airrel/where_clause.rb', line 28 def to_airtable_formula return nil if @predicates.empty? return @predicates.first if @predicates.size == 1 "AND(#{@predicates.join(", ")})" end |