module BettyResource::Model::Property::Types::HasAndBelongsToMany

Public Instance Methods

collection?() click to toggle source
# File lib/betty_resource/model/property/types/has_and_belongs_to_many.rb, line 8
def collection?
  true
end
typecast(record, value) click to toggle source
# 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