Module: Relata::Dsl::CustomRelation
- Includes:
- Conditions, Constraints
- Defined in:
- lib/relata/dsl/custom_relation.rb
Overview
defines helper methods to deal with custom relation
Instance Method Summary collapse
Methods included from Constraints
#count, #is_null, #length, #like?
Methods included from Conditions
#eq, #exists?, #ge, #greater_or_equals, #greater_than, #gt, #le, #lesser_than, #lt
Instance Method Details
#relates_belongs_to? ⇒ Boolean
32 33 34 |
# File 'lib/relata/dsl/custom_relation.rb', line 32 def relates_belongs_to? check_relation "belongs_to" end |
#relates_to_many? ⇒ Boolean
28 29 30 |
# File 'lib/relata/dsl/custom_relation.rb', line 28 def relates_to_many? check_relation "has_many" end |
#using(record, field) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/relata/dsl/custom_relation.rb', line 6 def using(record, field) @record = record @current_field = field @start_field = field @select_fields = ["#{table_name}.*"] @groups = [] if relates_to_many? self.extend MultipleQuery self.extend ModelFields elsif relates_belongs_to? self.extend BelongsToQuery self.extend ModelFields else self.extend SimpleQuery end self end |