Sha256: 6bacb2905629bdc0fc3f03fb06b38e99706eb1c3659b102a5c3579c768d93dc7

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

module Expressir
  module Model
    class Entity
      include Scope
      include Identifier

      attr_accessor :abstract
      attr_accessor :supertype_expression
      attr_accessor :subtype_of
      attr_accessor :attributes
      attr_accessor :unique
      attr_accessor :where

      def initialize(options = {})
        @id = options[:id]

        @abstract = options[:abstract]
        @supertype_expression = options[:supertype_expression]
        @subtype_of = options[:subtype_of]
        @attributes = options[:attributes]
        @unique = options[:unique]
        @where = options[:where]
      end

      def explicit_attributes
        @attributes.select{|x| x.kind == Expressir::Model::Attribute::EXPLICIT}
      end

      def derived_attributes
        @attributes.select{|x| x.kind == Expressir::Model::Attribute::DERIVED}
      end

      def inverse_attributes
        @attributes.select{|x| x.kind == Expressir::Model::Attribute::INVERSE}
      end

      def children
        items = []
        items.push(*@attributes) if @attributes
        items.push(*@unique) if @unique
        items.push(*@where) if @where
        items
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
expressir-0.2.6 lib/expressir/model/entity.rb
expressir-0.2.5-x64-mingw32 lib/expressir/model/entity.rb
expressir-0.2.4-x64-mingw32 lib/expressir/model/entity.rb