class Graphoid::Relation
Attributes
inverse_name[R]
klass[R]
name[R]
type[R]
Public Class Methods
new(relation)
click to toggle source
# File lib/graphoid/operators/relation.rb, line 7 def initialize(relation) @name = relation.name.to_s @camel_name = Utils.camelize(@name) @inverse_name = Graphoid.driver.inverse_name_of(relation) @klass = relation.class_name.constantize @type = Graphoid.driver.relation_type(relation) end
relations_of(model)
click to toggle source
# File lib/graphoid/operators/relation.rb, line 62 def relations_of(model) # return a list of relation objects # Graphoid.driver.relations_of(model).map { |_, relation| Relation.new(relation) } Graphoid.driver.relations_of(model) end
Public Instance Methods
belongs?()
click to toggle source
# File lib/graphoid/operators/relation.rb, line 35 def belongs? belongs_to? || embedded_in? end
create(_, _, _)
click to toggle source
# File lib/graphoid/operators/relation.rb, line 49 def create(_, _, _); end
embedded?()
click to toggle source
# File lib/graphoid/operators/relation.rb, line 43 def embedded? embeds_one? || embeds_many? || embedded_in? end
many?()
click to toggle source
# File lib/graphoid/operators/relation.rb, line 30 def many? # TODO: "through" can be one or many, we only support many at the moment. has_many? || has_and_belongs_to_many? || through? || embeds_many? end
many_to_many?()
click to toggle source
# File lib/graphoid/operators/relation.rb, line 39 def many_to_many? has_and_belongs_to_many? || through? end
one?()
click to toggle source
# File lib/graphoid/operators/relation.rb, line 26 def one? belongs_to? || has_one? || embeds_one? end
precreate(_)
click to toggle source
# File lib/graphoid/operators/relation.rb, line 47 def precreate(_); end
relation?()
click to toggle source
# File lib/graphoid/operators/relation.rb, line 22 def relation? true end
resolve(operation)
click to toggle source
# File lib/graphoid/operators/relation.rb, line 51 def resolve(operation) if one? || operation.operand.embedded? return operation.operand.exec(operation.scope, operation.value) end if many? return Graphoid.driver.relate_many(operation.scope, operation.operand, operation.value, operation.operator) end end