Class: VitaminedGems::VitaminedGem
- Inherits:
-
Object
- Object
- VitaminedGems::VitaminedGem
- Defined in:
- lib/vitamined-gems.rb
Instance Method Summary collapse
-
#initialize(rails_configuration, vitamins) ⇒ VitaminedGem
constructor
A new instance of VitaminedGem.
- #method_missing(vitamin_name, gem_name, options = {}) ⇒ Object
- #respond_to?(method) ⇒ Boolean
Constructor Details
#initialize(rails_configuration, vitamins) ⇒ VitaminedGem
Returns a new instance of VitaminedGem.
32 33 34 35 |
# File 'lib/vitamined-gems.rb', line 32 def initialize(rails_configuration, vitamins) @rails_configuration = rails_configuration @vitamins = vitamins end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(vitamin_name, gem_name, options = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/vitamined-gems.rb', line 41 def method_missing(vitamin_name, gem_name, = {}) if vitamin = @vitamins[vitamin_name] = if vitamin.is_a? Hash vitamin.merge() else vitamin.call(gem_name, ).merge() end @rails_configuration.gem(gem_name, ) else raise UnknownVitamin.new(vitamin_name) end end |
Instance Method Details
#respond_to?(method) ⇒ Boolean
37 38 39 |
# File 'lib/vitamined-gems.rb', line 37 def respond_to?(method) @vitamins.has_key?(method.to_sym) || super.respond_to?(method) end |