Sha256: 88912dcc50ba81cb540ea1ef4c0d53ddf1efb1ae3e2e2010bc77382368691bf3

Contents?: true

Size: 1.16 KB

Versions: 13

Compression:

Stored size: 1.16 KB

Contents

class Card
  module Query
    class CardQuery
      # interpret CQL attributes that involve references from one card to another
      module ReferenceAttributes
        def self.define_reference_method methodname, reftype, ref_method, ref_field
          define_method methodname do |val|
            tie :reference,
                { ref_method => { reftype: reftype, card: val } },
                to: ref_field
          end
        end

        {
          refer_to: %w[L I],
          link_to:  "L",
          include:  "I"
        }.each do |methodname, reftype|
          define_reference_method methodname, reftype, :referee, :referer_id
        end

        {
          referred_to_by: %w[L I],
          linked_to_by:   "L",
          included_by:    "I"
        }.each do |methodname, reftype|
          define_reference_method methodname, reftype, :referer, :referee_id
        end

        # shortcut methods for role references
        # DEPRECATE?

        def member_of val
          interpret right_plus: [RolesID, refer_to: val]
        end

        def member val
          interpret referred_to_by: { left: val, right: RolesID }
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
card-1.96.8 lib/card/query/card_query/reference_attributes.rb
card-1.96.7 lib/card/query/card_query/reference_attributes.rb
card-1.96.6 lib/card/query/card_query/reference_attributes.rb
card-1.96.5 lib/card/query/card_query/reference_attributes.rb
card-1.96.4 lib/card/query/card_query/reference_attributes.rb
card-1.96.3 lib/card/query/card_query/reference_attributes.rb
card-1.96.2 lib/card/query/card_query/reference_attributes.rb
card-1.96.1 lib/card/query/card_query/reference_attributes.rb
card-1.96.0 lib/card/query/card_query/reference_attributes.rb
card-1.95.3 lib/card/query/card_query/reference_attributes.rb
card-1.95.2 lib/card/query/card_query/reference_attributes.rb
card-1.95.1 lib/card/query/card_query/reference_attributes.rb
card-1.95.0 lib/card/query/card_query/reference_attributes.rb