Class: RgGen::Core::Builder::Layer

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

Defined Under Namespace

Classes: Proxy

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Layer

Returns a new instance of Layer.



54
55
56
57
# File 'lib/rggen/core/builder/layer.rb', line 54

def initialize(name)
  @name = name
  @feature_registries = {}
end

Instance Method Details

#add_feature_registry(name, registry) ⇒ Object



59
60
61
62
# File 'lib/rggen/core/builder/layer.rb', line 59

def add_feature_registry(name, registry)
  @feature_registries[name] = registry
  define_proxy_call(name)
end

#component(name) ⇒ Object



64
65
66
67
68
69
# File 'lib/rggen/core/builder/layer.rb', line 64

def component(name, &)
  registory =
    @feature_registries
      .fetch(name) { raise BuilderError.new("unknown component: #{name}") }
  block_given? && @proxy.register_execution(registory, &)
end

#component_defined?(component_name) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/rggen/core/builder/layer.rb', line 82

def component_defined?(component_name)
  @feature_registries.key?(component_name)
end

#define_feature(feature_names) ⇒ Object



86
87
88
89
90
# File 'lib/rggen/core/builder/layer.rb', line 86

def define_feature(feature_names, &)
  Array(feature_names).each do |feature_name|
    do_proxy_call(__method__, feature_name:, use_shared_context: true, &)
  end
end

#define_list_feature(list_names) ⇒ Object



110
111
112
113
114
# File 'lib/rggen/core/builder/layer.rb', line 110

def define_list_feature(list_names, &)
  Array(list_names).each do |list_name|
    do_proxy_call(__method__, list_name:, use_shared_context: true, &)
  end
end

#define_list_item_feature(list_name, feature_names) ⇒ Object



122
123
124
125
126
127
128
# File 'lib/rggen/core/builder/layer.rb', line 122

def define_list_item_feature(list_name, feature_names, &)
  Array(feature_names).each do |feature_name|
    do_proxy_call(
      __method__, list_name:, feature_name:, use_shared_context: true, &
    )
  end
end

#define_simple_feature(feature_names) ⇒ Object



98
99
100
101
102
# File 'lib/rggen/core/builder/layer.rb', line 98

def define_simple_feature(feature_names, &)
  Array(feature_names).each do |feature_name|
    do_proxy_call(__method__, feature_name:, use_shared_context: true, &)
  end
end

#deleteObject



146
147
148
149
150
# File 'lib/rggen/core/builder/layer.rb', line 146

def delete(...)
  @feature_registries.each_value do |registry|
    registry.delete(...)
  end
end

#delete_allObject



152
153
154
# File 'lib/rggen/core/builder/layer.rb', line 152

def delete_all
  @feature_registries.each_value(&:delete_all)
end

#enableObject



136
137
138
139
140
# File 'lib/rggen/core/builder/layer.rb', line 136

def enable(...)
  @feature_registries.each_value do |registry|
    registry.enable(...)
  end
end

#enable_allObject



142
143
144
# File 'lib/rggen/core/builder/layer.rb', line 142

def enable_all
  @feature_registries.each_value(&:enable_all)
end

#modify_feature(feature_names) ⇒ Object



92
93
94
95
96
# File 'lib/rggen/core/builder/layer.rb', line 92

def modify_feature(feature_names, &)
  Array(feature_names).each do |feature_name|
    do_proxy_call(__method__, feature_name:, &)
  end
end

#modify_list_feature(list_names) ⇒ Object



116
117
118
119
120
# File 'lib/rggen/core/builder/layer.rb', line 116

def modify_list_feature(list_names, &)
  Array(list_names).each do |list_name|
    do_proxy_call(__method__, list_name:, &)
  end
end

#modify_list_item_feature(list_name, feature_names) ⇒ Object



130
131
132
133
134
# File 'lib/rggen/core/builder/layer.rb', line 130

def modify_list_item_feature(list_name, feature_names, &)
  Array(feature_names).each do |feature_name|
    do_proxy_call(__method__, list_name:, feature_name:, &)
  end
end

#modify_simple_feature(feature_names) ⇒ Object



104
105
106
107
108
# File 'lib/rggen/core/builder/layer.rb', line 104

def modify_simple_feature(feature_names, &)
  Array(feature_names).each do |feature_name|
    do_proxy_call(__method__, feature_name:, &)
  end
end

#shared_contextObject



71
72
73
74
75
76
77
78
79
80
# File 'lib/rggen/core/builder/layer.rb', line 71

def shared_context(&)
  return unless @proxy

  if block_given?
    context = current_shared_context(true)
    context.singleton_exec(&)
  end

  current_shared_context(false)
end