Module: Hecks::Bluebook::Behaviour::Identified
Overview
A CONSTRUCT WHOSE IDENTITY IS A JOIN OF DECLARED PATHS.
THE PATHS, IN DECLARATION ORDER, because the identity IS their join.
"number.value" says which field carries the identity ; several paths
say the identity is made of several facts, which is what anything
named beneath another thing needs. identity_heads are the attributes
those paths start at — what every reader that looks up or coerces an
attribute actually wants — and identified_by is the single head,
offered ONLY when there is one path to have a head of. A composite has
no single head, and answering with the first would be a guess ; the
readers that need all of them ask for identity_heads.
Instance Method Summary collapse
Instance Method Details
#derive_identity ⇒ Object
31 32 33 34 35 |
# File 'lib/hecks/bluebook/behaviour/traits.rb', line 31 def derive_identity @identity_paths = Array(@identified_by).map { |path| path.to_s }.reject(&:empty?) @identity_heads = @identity_paths.map { |path| path.split(".").first.to_sym }.uniq @identified_by = @identity_heads.size == 1 ? @identity_heads.first : nil end |