Class: RgGen::Core::Base::FeatureFactory

Inherits:
Object
  • Object
show all
Extended by:
SharedContext
Defined in:
lib/rggen/core/base/feature_factory.rb

Instance Method Summary collapse

Methods included from SharedContext

attach_context

Constructor Details

#initialize(feature_name) ⇒ FeatureFactory

Returns a new instance of FeatureFactory.



9
10
11
12
# File 'lib/rggen/core/base/feature_factory.rb', line 9

def initialize(feature_name)
  @feature_name = feature_name
  block_given? && yield(self)
end

Instance Method Details

#create_feature(component, *args) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/rggen/core/base/feature_factory.rb', line 17

def create_feature(component, *args)
  klass, sub_feature_name = select_feature(*args)
  klass.new(@feature_name, sub_feature_name, component) do |feature|
    feature.available? || break
    block_given? && yield(feature)
    component.add_feature(feature)
  end
end