Module: RubyFeatures
- Defined in:
- lib/ruby-features.rb,
lib/ruby-features/lazy.rb,
lib/ruby-features/utils.rb,
lib/ruby-features/mixins.rb,
lib/ruby-features/version.rb,
lib/ruby-features/container.rb,
lib/ruby-features/conditions.rb,
lib/ruby-features/concern/feature.rb,
lib/ruby-features/utils/inflector.rb,
lib/ruby-features/concern/apply_to.rb,
lib/ruby-features/utils/const_accessor_19.rb,
lib/ruby-features/utils/const_accessor_20.rb,
lib/generators/ruby_features/install_generator.rb,
lib/ruby-features/utils/inflector_active_support.rb
Defined Under Namespace
Modules: Concern, Generators, Lazy, Mixins, Utils
Classes: ApplyError, Conditions, Container
Constant Summary
collapse
- VERSION =
'1.2.1'.freeze
Class Method Summary
collapse
Class Method Details
.active_support_available? ⇒ Boolean
57
58
59
|
# File 'lib/ruby-features.rb', line 57
def active_support_available?
@active_support_available
end
|
.apply(*feature_names) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/ruby-features.rb', line 49
def apply(*feature_names)
feature_names.each do |feature_name|
raise NameError.new("Such feature is not registered: #{feature_name}") unless @features.has_key?(feature_name)
@features[feature_name].apply
end
end
|
.define(feature_name, &feature_body) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/ruby-features.rb', line 41
def define(feature_name, &feature_body)
feature_name = feature_name.to_s
raise NameError.new("Wrong feature name: #{feature_name}") unless feature_name.match(/^[\/_a-z\d]+$/)
raise NameError.new("Such feature is already registered: #{feature_name}") if @features.has_key?(feature_name)
@features[feature_name] = Mixins.new(feature_name, feature_body)
end
|
.find_in_path(*folders) ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/ruby-features.rb', line 31
def find_in_path(*folders)
old_feature_names = @features.keys
Dir[*folders.map{|folder| File.join(folder, '**', '*_feature.rb') }].each do |file|
require file
end
Container.new(@features.keys - old_feature_names)
end
|