class RgGen::Core::Builder::ListFeatureEntry

Attributes

name[R]
registry[R]

Public Class Methods

new(registry, name) click to toggle source
# File lib/rggen/core/builder/list_feature_entry.rb, line 9
def initialize(registry, name)
  @registry = registry
  @name = name
  @features = {}
end

Public Instance Methods

base_feature(&body)
Alias for: define_base_feature
build_factory(enabled_features) click to toggle source
# File lib/rggen/core/builder/list_feature_entry.rb, line 35
def build_factory(enabled_features)
  @factory.new(@name) do |f|
    f.target_features(target_features(enabled_features))
    f.target_feature(@default_feature)
  end
end
default_feature(&body)
define_base_feature(&body) click to toggle source
# File lib/rggen/core/builder/list_feature_entry.rb, line 42
def define_base_feature(&body)
  body && @base_feature.class_exec(&body)
end
Also aliased as: base_feature
define_default_feature(&body) click to toggle source
# File lib/rggen/core/builder/list_feature_entry.rb, line 61
def define_default_feature(&body)
  @default_feature ||= Class.new(@base_feature)
  body && @default_feature.class_exec(&body)
end
Also aliased as: default_feature
define_factory(&body) click to toggle source
# File lib/rggen/core/builder/list_feature_entry.rb, line 29
def define_factory(&body)
  @factory.class_exec(&body)
end
Also aliased as: factory
define_feature(feature_name, context = nil, &body) click to toggle source
# File lib/rggen/core/builder/list_feature_entry.rb, line 48
def define_feature(feature_name, context = nil, &body)
  @features[feature_name] ||= Class.new(@base_feature)
  feature = @features[feature_name]
  if context
    feature.method_defined?(:shared_context) &&
      (raise BuilderError.new('shared context has already been set'))
    feature.attach_context(context)
  end
  body && feature.class_exec(feature_name, &body)
end
Also aliased as: feature
delete(features = nil) click to toggle source
# File lib/rggen/core/builder/list_feature_entry.rb, line 68
def delete(features = nil)
  if features
    Array(features).each { |feature| @features.delete(feature) }
  else
    @features.clear
  end
end
factory(&body)
Alias for: define_factory
feature(feature_name, context = nil, &body)
Alias for: define_feature
feature?(feature) click to toggle source
# File lib/rggen/core/builder/list_feature_entry.rb, line 76
def feature?(feature)
  @features.key?(feature)
end
match_entry_type?(entry_type) click to toggle source
# File lib/rggen/core/builder/list_feature_entry.rb, line 25
def match_entry_type?(entry_type)
  entry_type == :list
end
setup(base_feature, base_factory, context, &body) click to toggle source
# File lib/rggen/core/builder/list_feature_entry.rb, line 18
def setup(base_feature, base_factory, context, &body)
  @base_feature = Class.new(base_feature)
  @factory = Class.new(base_factory)
  context && attach_shared_context(context)
  block_given? && Docile.dsl_eval(self, @name, &body)
end

Private Instance Methods

attach_shared_context(context) click to toggle source
# File lib/rggen/core/builder/list_feature_entry.rb, line 82
def attach_shared_context(context)
  [@factory, @base_feature, self].each do |target|
    target.attach_context(context)
  end
end
target_features(enabled_features) click to toggle source
# File lib/rggen/core/builder/list_feature_entry.rb, line 88
def target_features(enabled_features)
  @features.slice(*enabled_features)
end