module Conjunction::Conjunctive

Conjunctives are Prototypes that can be `conjugated` with a Junction into a specific Conjunction.

Public Instance Methods

conjoins(junction) click to toggle source
# File lib/conjunction/conjunctive.rb, line 41
def conjoins(junction)
  raise TypeError, "#{junction} is not a valid junction" unless junction.respond_to?(:junction_key)

  explicit_conjunctions[junction.junction_key] = junction
end
conjugate(junction) click to toggle source
# File lib/conjunction/conjunctive.rb, line 17
def conjugate(junction)
  conjugate_with(junction, :conjunction_for)
end
conjugate!(junction) click to toggle source
# File lib/conjunction/conjunctive.rb, line 21
def conjugate!(junction)
  conjugate_with(junction, :conjunction_for!)
end
conjugate_with(junction, method_name) click to toggle source
# File lib/conjunction/conjunctive.rb, line 32
def conjugate_with(junction, method_name)
  conjunction = explicit_conjunctions[junction.try(:junction_key)] || Nexus.conjugate(self, junction: junction)
  return conjunction if conjunction.present?

  return if Conjunction.config.nexus_use_disables_implicit_lookup && Nexus.couples?(junction)

  junction.try(method_name, prototype, prototype_name) unless Conjunction.config.disable_all_implicit_lookup
end
inherited(base) click to toggle source
Calls superclass method
# File lib/conjunction/conjunctive.rb, line 25
def inherited(base)
  base.explicit_conjunctions = {}
  super
end