Sha256: 6c41ac7c0ca354bbbbb88cfa64d37291a269bf9032ebaa7b1e6c390444de0014

Contents?: true

Size: 1.6 KB

Versions: 18

Compression:

Stored size: 1.6 KB

Contents

module Expressir
  module Model
    class Rule
      include Scope
      include Identifier

      attr_accessor :applies_to
      attr_accessor :declarations
      attr_accessor :constants
      attr_accessor :variables
      attr_accessor :statements
      attr_accessor :where

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

        @applies_to = options[:applies_to]
        @declarations = options[:declarations]
        @constants = options[:constants]
        @variables = options[:variables]
        @statements = options[:statements]
        @where = options[:where]
      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 children
        items = []
        items.push(*@declarations.flat_map do |x|
          [
            x,
            *if x.instance_of? Expressir::Model::Type and x.type.instance_of? Expressir::Model::Types::Enumeration
              x.type.items
            end
          ]
        end) if @declarations
        items.push(*@constants) if @constants
        items.push(*@variables) if @variables
        items.push(*@where) if @where
        items
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
expressir-0.2.8 lib/expressir/model/rule.rb
expressir-0.2.8-x86_64-linux lib/expressir/model/rule.rb
expressir-0.2.8-x86_64-darwin lib/expressir/model/rule.rb
expressir-0.2.8-x86-mingw32 lib/expressir/model/rule.rb
expressir-0.2.8-x86-linux lib/expressir/model/rule.rb
expressir-0.2.8-x64-mingw32 lib/expressir/model/rule.rb
expressir-0.2.8-arm64-darwin lib/expressir/model/rule.rb
expressir-0.2.7 lib/expressir/model/rule.rb
expressir-0.2.7-x86-mingw32 lib/expressir/model/rule.rb
expressir-0.2.7-x64-mingw32 lib/expressir/model/rule.rb
expressir-0.2.7-x86_64-linux lib/expressir/model/rule.rb
expressir-0.2.7-x86-linux lib/expressir/model/rule.rb
expressir-0.2.7-x86_64-darwin lib/expressir/model/rule.rb
expressir-0.2.7-arm64-darwin lib/expressir/model/rule.rb
expressir-0.2.5-x86_64-linux lib/expressir/model/rule.rb
expressir-0.2.5-x86_64-darwin-19 lib/expressir/model/rule.rb
expressir-0.2.5 lib/expressir/model/rule.rb
expressir-0.2.4 lib/expressir/model/rule.rb