Sha256: fb34881ca28c22bb9ef65a75fba1b1fc759507e5c5f961cea13cbecbf262992b

Contents?: true

Size: 875 Bytes

Versions: 11

Compression:

Stored size: 875 Bytes

Contents

module Rasti
  module DB
    module NQL
      module Nodes
        class Attribute < Treetop::Runtime::SyntaxNode

          def identifier(collection_class)
            if computed? collection_class
              collection_class.computed_attributes[column].identifier
            else
              tables.empty? ? Sequel[column] : Sequel[tables.join('__').to_sym][column]
            end
          end

          def tables
            _tables.elements.map{ |e| e.table.text_value }
          end

          def column
            _column.text_value.to_sym
          end

          def computed_attributes(collection_class)
            computed?(collection_class) ? [column] : []
          end

          private

          def computed?(collection_class)
            collection_class.computed_attributes.key? column
          end

        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rasti-db-4.2.0 lib/rasti/db/nql/nodes/attribute.rb
rasti-db-4.1.1 lib/rasti/db/nql/nodes/attribute.rb
rasti-db-4.1.0 lib/rasti/db/nql/nodes/attribute.rb
rasti-db-4.0.0 lib/rasti/db/nql/nodes/attribute.rb
rasti-db-3.0.0 lib/rasti/db/nql/nodes/attribute.rb
rasti-db-2.3.3 lib/rasti/db/nql/nodes/attribute.rb
rasti-db-2.3.2 lib/rasti/db/nql/nodes/attribute.rb
rasti-db-2.3.1 lib/rasti/db/nql/nodes/attribute.rb
rasti-db-2.3.0 lib/rasti/db/nql/nodes/attribute.rb
rasti-db-2.2.0 lib/rasti/db/nql/nodes/attribute.rb
rasti-db-2.1.0 lib/rasti/db/nql/nodes/attribute.rb