Sha256: 460e7e0dba3dae8e824191edbb973774a3fdc4cd98696d58b490851693f0da88

Contents?: true

Size: 1.62 KB

Versions: 6

Compression:

Stored size: 1.62 KB

Contents

class Card
  module Query
    class CardQuery
      # interpret CQL attributes that relate multiple cards
      # each method below corresponds to a relational CQL term
      #
      # NOTE: methods using "restrict" can  be executed without
      # tying in an additional query if the val in question can be
      # reduced to an id.
      module RelationalAttributes
        def type val
          restrict :type_id, val
        end

        def part val
          right_val = val.is_a?(Integer) ? val : val.clone
          any(left: val, right: right_val)
        end

        def left val
          restrict :left_id, val
        end

        def right val
          restrict :right_id, val
        end

        def editor_of val
          tie_act :action_on, val
        end

        def updater_of val
          tie_act :update_action_on, val
        end

        def edited_by val
          tie_action :action_by, val
        end

        def updated_by val
          tie_action :update_action_by, val
        end

        def last_editor_of val
          tie :card, val, to: :updater_id
        end

        def last_edited_by val
          restrict :updater_id, val
        end

        def creator_of val
          tie :card, val, to: :creator_id
        end

        def created_by val
          restrict :creator_id, val
        end

        # ~~~~~~ PLUS RELATIONAL

        def left_plus val
          junction val, :left, :right_id
        end

        def right_plus val
          junction val, :right, :left_id
        end

        def plus val
          any(left_plus: val, right_plus: val.deep_clone)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
card-1.96.1 lib/card/query/card_query/relational_attributes.rb
card-1.96.0 lib/card/query/card_query/relational_attributes.rb
card-1.95.3 lib/card/query/card_query/relational_attributes.rb
card-1.95.2 lib/card/query/card_query/relational_attributes.rb
card-1.95.1 lib/card/query/card_query/relational_attributes.rb
card-1.95.0 lib/card/query/card_query/relational_attributes.rb