class JsonApiModel::Associations::Has
Public Instance Methods
action()
click to toggle source
# File lib/json_api_model/associations/has.rb, line 5 def action :where end
additional_options()
click to toggle source
# File lib/json_api_model/associations/has.rb, line 9 def additional_options [ :as, :through ] end
ids( instance )
click to toggle source
# File lib/json_api_model/associations/has.rb, line 23 def ids( instance ) if json_relationship? instance.relationship_ids( name ) elsif through? target_ids( instance ) else instance.id end end
key()
click to toggle source
# File lib/json_api_model/associations/has.rb, line 13 def key if json_relationship? || through? :id elsif as? "#{as}_id" else idify( base_class ) end end
query( instance )
click to toggle source
# File lib/json_api_model/associations/has.rb, line 33 def query( instance ) { key => ids( instance ) } end
Protected Instance Methods
as()
click to toggle source
# File lib/json_api_model/associations/has.rb, line 47 def as opts[:as] end
as?()
click to toggle source
# File lib/json_api_model/associations/has.rb, line 51 def as? opts.has_key? :as end
target_ids( instance )
click to toggle source
# File lib/json_api_model/associations/has.rb, line 55 def target_ids( instance ) intermediates = Array(instance.send( through ) ) intermediates.map do | intermediate | intermediate.send( through_key ) end end
through()
click to toggle source
# File lib/json_api_model/associations/has.rb, line 39 def through opts[:through] end
through?()
click to toggle source
# File lib/json_api_model/associations/has.rb, line 43 def through? opts.has_key? :through end
through_key()
click to toggle source
# File lib/json_api_model/associations/has.rb, line 63 def through_key idify association_class end