Class: RgGen::Builder::Category

Inherits:
Object
  • Object
show all
Defined in:
lib/rggen/builder/category.rb

Instance Method Summary collapse

Constructor Details

#initializeCategory

Returns a new instance of Category.



4
5
6
# File 'lib/rggen/builder/category.rb', line 4

def initialize
  @item_stores  = {}
end

Instance Method Details

#add_item_store(component_name, item_store) ⇒ Object



8
9
10
11
12
# File 'lib/rggen/builder/category.rb', line 8

def add_item_store(component_name, item_store)
  return if @item_stores.key?(component_name)
  @item_stores[component_name]  = item_store
  define_definition_method(component_name)
end

#define_list_item(list_name, item_name = nil, &body) ⇒ Object



18
19
20
# File 'lib/rggen/builder/category.rb', line 18

def define_list_item(list_name, item_name = nil, &body)
  do_definition(:define_list_item, list_name, item_name, &body)
end

#define_simple_item(item_name, &body) ⇒ Object



14
15
16
# File 'lib/rggen/builder/category.rb', line 14

def define_simple_item(item_name, &body)
  do_definition(:define_simple_item, item_name, &body)
end

#enable(*args) ⇒ Object



27
28
29
30
31
# File 'lib/rggen/builder/category.rb', line 27

def enable(*args)
  @item_stores.each_value do |item_registry|
    item_registry.enable(*args)
  end
end

#shared_context(&body) ⇒ Object



22
23
24
25
# File 'lib/rggen/builder/category.rb', line 22

def shared_context(&body)
  @shared_context ||= Object.new
  @shared_context.singleton_class.class_exec(&body) if block_given?
end