Module: BettyResource::Model::Property::Types::HasAndBelongsToMany

Includes:
Association
Defined in:
lib/betty_resource/model/property/types/has_and_belongs_to_many.rb

Instance Method Summary collapse

Instance Method Details

#collection?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/betty_resource/model/property/types/has_and_belongs_to_many.rb', line 8

def collection?
  true
end

#typecast(record, value) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/betty_resource/model/property/types/has_and_belongs_to_many.rb', line 12

def typecast(record, value)
  filter = {
    'operator' => 'and',
    'conditions' => [
      'path' => [inverse_property.id, model.property(:id).id],
      'predicate' => 'eq',
      'criteria' => record.id
    ]
  }

  target_model.all :filters => [filter]
end