Class: ConfigTemplates::Collections::Extensions
- Inherits:
-
Object
- Object
- ConfigTemplates::Collections::Extensions
- Defined in:
- lib/config_templates/collections/extensions.rb
Instance Method Summary collapse
- #add(extensions) ⇒ Object
- #exists_with_name?(name) ⇒ Boolean
- #find_by(criteria) ⇒ Object
- #find_by_name(name) ⇒ Object
-
#initialize ⇒ Extensions
constructor
A new instance of Extensions.
Constructor Details
#initialize ⇒ Extensions
Returns a new instance of Extensions.
3 4 5 6 7 8 |
# File 'lib/config_templates/collections/extensions.rb', line 3 def initialize @extensions = { /^.+\?$/ => proc { |*args| ::ConfigTemplates::Extensions::Stage.new.call *args }, 'include' => proc { |*args| ::ConfigTemplates::Extensions::Include.new.call *args } } end |
Instance Method Details
#add(extensions) ⇒ Object
10 11 12 |
# File 'lib/config_templates/collections/extensions.rb', line 10 def add(extensions) @extensions.merge! extensions end |
#exists_with_name?(name) ⇒ Boolean
14 15 16 |
# File 'lib/config_templates/collections/extensions.rb', line 14 def exists_with_name?(name) find_by_name(name) != nil end |
#find_by(criteria) ⇒ Object
22 23 24 25 26 |
# File 'lib/config_templates/collections/extensions.rb', line 22 def find_by(criteria) criteria.filter(@extensions).first.last rescue nil end |
#find_by_name(name) ⇒ Object
18 19 20 |
# File 'lib/config_templates/collections/extensions.rb', line 18 def find_by_name(name) find_by ::ConfigTemplates::Criteria::Name.new name end |