Sha256: e34f3474eb420c881ba9cdc55d9aa152072b02ddbc6dfd6ce72cb6f100df17ad

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

module Expressir
  module Model
    class Entity
      attr_accessor :id
      attr_accessor :abstract
      attr_accessor :supertype_expression
      attr_accessor :subtype_of
      attr_accessor :attributes
      attr_accessor :unique
      attr_accessor :where

      attr_accessor :parent
      attr_accessor :remarks

      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

1 entries across 1 versions & 1 rubygems

Version Path
expressir-0.2.3 lib/expressir/model/entity.rb