Sha256: 3358198a875144240ccd98c35c232ccd68cc1e62387ed68b3951eb206d6f8f8a

Contents?: true

Size: 1004 Bytes

Versions: 19

Compression:

Stored size: 1004 Bytes

Contents

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

    # singleton class
    class Users
      
      attr_accessor :nodes
      
      def initialize
        @nodes ||= {}
      end
      
      def self.instance
        @__instance__ ||= new
      end
      
      #
      # Register a new user in the list.
      #
      def register( name )
        # retrive or initialize a entity
        user = element(name) || User.new( name )
        yield(user) if block_given?
        add_node user # add to the list
      end
    
      #
      # Add note to the entity list
      # Prevents entity duplication
      #
      def add_node(node)
        @nodes[node.name] = node
      end
      
      def element(e)
        @nodes[e]
      end
      
      def all
        @nodes.values
      end

    end # class entitites
    
    # return the entities instance
    def self.users
      Users.instance
    end
    
    def self.user(name)
      self.users.element(name)
    end

    
  end # dsl
end # mdd

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
mdd-3.1.4 lib/mdwa/dsl/users.rb
mdd-3.1.2 lib/mdwa/dsl/users.rb
mdd-3.1.1 lib/mdwa/dsl/users.rb
mdd-3.1.0 lib/mdwa/dsl/users.rb
mdd-3.0.20 lib/mdwa/dsl/users.rb
mdd-3.0.19 lib/mdwa/dsl/users.rb
mdd-3.0.18 lib/mdwa/dsl/users.rb
mdd-3.0.17 lib/mdwa/dsl/users.rb
mdd-3.0.16 lib/mdwa/dsl/users.rb
mdd-3.0.15 lib/mdwa/dsl/users.rb
mdd-3.0.14 lib/mdwa/dsl/users.rb
mdd-3.0.13 lib/mdwa/dsl/users.rb
mdd-3.0.10 lib/mdwa/dsl/users.rb
mdd-3.0.9 lib/mdwa/dsl/users.rb
mdd-3.0.8 lib/mdwa/dsl/users.rb
mdd-3.0.7 lib/mdwa/dsl/users.rb
mdd-3.0.6 lib/mdwa/dsl/users.rb
mdd-3.0.4 lib/mdwa/dsl/users.rb
mdd-3.0.3 lib/mdwa/dsl/users.rb