Class: RgGen::Core::Builder::ListFeatureEntry
Instance Attribute Summary
#name, #registry
Instance Method Summary
collapse
#attach_context
#build_factory, #match_entry_type?, #modify
Constructor Details
Returns a new instance of ListFeatureEntry.
9
10
11
12
|
# File 'lib/rggen/core/builder/list_feature_entry.rb', line 9
def initialize(registry, name)
super(registry, name)
@features = {}
end
|
Instance Method Details
#define_base_feature(&body) ⇒ Object
Also known as:
base_feature
27
28
29
|
# File 'lib/rggen/core/builder/list_feature_entry.rb', line 27
def define_base_feature(&body)
body && @base_feature.class_exec(&body)
end
|
#define_default_feature(&body) ⇒ Object
Also known as:
default_feature
51
52
53
54
|
# File 'lib/rggen/core/builder/list_feature_entry.rb', line 51
def define_default_feature(&body)
@default_feature ||= Class.new(@base_feature)
body && @default_feature.class_exec(&body)
end
|
#define_factory(&body) ⇒ Object
Also known as:
factory
21
22
23
|
# File 'lib/rggen/core/builder/list_feature_entry.rb', line 21
def define_factory(&body)
@factory.class_exec(&body)
end
|
#define_feature(feature_name, context = nil, &body) ⇒ Object
Also known as:
feature
33
34
35
36
37
38
39
40
41
|
# File 'lib/rggen/core/builder/list_feature_entry.rb', line 33
def define_feature(feature_name, context = nil, &body)
feature = @features[feature_name] = Class.new(@base_feature)
if context
feature.method_defined?(:shared_context) &&
(raise BuilderError.new('shared context has already been set'))
attach_shared_context(context, feature)
end
body && feature.class_exec(feature_name, &body)
end
|
#delete(features = nil) ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/rggen/core/builder/list_feature_entry.rb', line 58
def delete(features = nil)
if features
Array(features).each { |feature| @features.delete(feature) }
else
@features.clear
end
end
|
#feature?(feature) ⇒ Boolean
66
67
68
|
# File 'lib/rggen/core/builder/list_feature_entry.rb', line 66
def feature?(feature)
@features.key?(feature)
end
|
70
71
72
|
# File 'lib/rggen/core/builder/list_feature_entry.rb', line 70
def features
@features.keys
end
|
#modify_feature(feature_name, &body) ⇒ Object
45
46
47
48
49
|
# File 'lib/rggen/core/builder/list_feature_entry.rb', line 45
def modify_feature(feature_name, &body)
@features.key?(feature_name) ||
(raise BuilderError.new("unknown feature: #{feature_name}"))
body && @features[feature_name].class_exec(feature_name, &body)
end
|
#setup(base_feature, base_factory, context, &body) ⇒ Object
14
15
16
17
18
19
|
# File 'lib/rggen/core/builder/list_feature_entry.rb', line 14
def setup(base_feature, base_factory, context, &body)
@base_feature = Class.new(base_feature)
@factory = Class.new(base_factory)
attach_shared_context(context, @base_feature, @factory, self)
eval_body(&body)
end
|