Sha256: f33dff71c0aaed7c6ff83e80b48e0c65e1970df05534dc59ddd9933b005e13c1

Contents?: true

Size: 744 Bytes

Versions: 1

Compression:

Stored size: 744 Bytes

Contents

# -*- encoding : utf-8 -*-
module MDWA
  module DSL

    # singleton class
    class Entities
      
      attr_accessor :nodes
      
      def initialize
        @nodes ||= {}
      end
      
      def self.instance
        @__instance__ ||= new
      end
      
      def register( name )        
        e = element(name) || Entity.new( name )
        yield e
        add_node e
      end
    
      def add_node(node)
        @nodes[node.name] = node
      end
      
      def element(e)
        @nodes[e]
      end

    end # class entitites
    
    # return the entities instance
    def self.entities
      Entities.instance
    end
    
    def self.entity(name)
      self.entities.element(name)
    end

    
  end # dsl
end # mdd

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mdd-3.0.0 lib/mdwa/dsl/entities.rb