Sha256: 3dae0ea785106f88fc09fc06ae47d3be009063ac83f7c4fe99da565d8756c303

Contents?: true

Size: 505 Bytes

Versions: 2

Compression:

Stored size: 505 Bytes

Contents

module Egi
  class Group
    def initialize(name = nil)
      @tags = name ? [ name ] : [ ]
      @default = {}
    end

    def set(default)
      @default = default
    end

    def instance_eval(&block)
      super
      self # for method chain
    end

    def items
      @items ||= Hash.new {|hash, key| hash[key] = Item[{ :name => key, :tags => @tags }.merge(@default)] }
    end

    def item(name, hash = {})
      items[name.to_sym].update(hash)
      self # for method chain
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
egi-0.0.4 lib/egi/group.rb
egi-0.0.3 lib/egi/group.rb