Sha256: a595df7e74bfc1088949715eafab2a3a3990e9a04064799f78ea9046a927c252

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

module Expressir
  module Model
    class Schema
      attr_accessor :id
      attr_accessor :version
      attr_accessor :interfaces
      attr_accessor :constants
      attr_accessor :declarations
      attr_accessor :rules
      attr_accessor :remarks

      def initialize(options = {})
        @id = options[:id]
        @version = options[:version]
        @interfaces = options[:interfaces]
        @constants = options[:constants]
        @declarations = options[:declarations]
        @rules = options[:rules]
        @remarks = options[:remarks]
      end

      def types
        @declarations.select{|x| x.instance_of? Expressir::Model::Type}
      end

      def entities
        @declarations.select{|x| x.instance_of? Expressir::Model::Entity}
      end

      def subtype_constraints
        @declarations.select{|x| x.instance_of? Expressir::Model::SubtypeConstraint}
      end

      def functions
        @declarations.select{|x| x.instance_of? Expressir::Model::Function}
      end

      def procedures
        @declarations.select{|x| x.instance_of? Expressir::Model::Procedure}
      end

      def scope_items
        items = []
        items.push(*@constants) if @constants
        items.push(*@declarations) if @declarations
        items.push(*@rules) if @rules
        items
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
expressir-0.2.2 lib/expressir/model/schema.rb
expressir-0.2.1 lib/expressir/model/schema.rb