Class: Egi::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/egi/group.rb

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ Group

Returns a new instance of Group.



3
4
5
6
# File 'lib/egi/group.rb', line 3

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

Instance Method Details

#instance_eval(&block) ⇒ Object



12
13
14
15
# File 'lib/egi/group.rb', line 12

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

#item(name, hash = {}) ⇒ Object



21
22
23
24
# File 'lib/egi/group.rb', line 21

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

#itemsObject



17
18
19
# File 'lib/egi/group.rb', line 17

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

#set(default) ⇒ Object



8
9
10
# File 'lib/egi/group.rb', line 8

def set(default)
  @default = default
end