module Conjunction::Junction
A Junction is an encapsulation of behavior which has been abstracted out of a Conjunctive.
Public Instance Methods
conjunction_for(other_prototype, prototype_name)
click to toggle source
# File lib/conjunction/junction.rb, line 31 def conjunction_for(other_prototype, prototype_name) conjunction_name_for(other_prototype, prototype_name)&.safe_constantize end
conjunction_for!(other_prototype, prototype_name)
click to toggle source
# File lib/conjunction/junction.rb, line 27 def conjunction_for!(other_prototype, prototype_name) conjunction_for(other_prototype, prototype_name) or raise DisjointedError, "#{other_prototype} #{name} unknown" end
conjunction_name_for(other_prototype, other_prototype_name)
click to toggle source
# File lib/conjunction/junction.rb, line 41 def conjunction_name_for(other_prototype, other_prototype_name) other_prototype_name = other_prototype.prototype_name if other_prototype.respond_to?(:prototype_name) return if other_prototype_name.blank? [ conjunction_prefix, other_prototype_name, conjunction_suffix ].compact.join if conjunctive? end
junction_key()
click to toggle source
# File lib/conjunction/junction.rb, line 16 def junction_key key_parts.join.underscore.parameterize(separator: "_").to_sym if conjunctive? end
key_parts()
click to toggle source
# File lib/conjunction/junction.rb, line 37 def key_parts [ conjunction_prefix, conjunction_suffix ].compact end
prototype_name()
click to toggle source
# File lib/conjunction/junction.rb, line 20 def prototype_name output = name output = output.delete_prefix(conjunction_prefix) if conjunction_prefix? output = output.delete_suffix(conjunction_suffix) if conjunction_suffix? output unless output == name end