Class: RspecVarsHelper::ClassMethods::VarsDSL
- Inherits:
-
Object
- Object
- RspecVarsHelper::ClassMethods::VarsDSL
- Defined in:
- lib/rspec_vars_helper.rb
Instance Method Summary collapse
-
#initialize(klass) ⇒ VarsDSL
constructor
A new instance of VarsDSL.
- #method_missing(method_name, *args, &block) ⇒ Object
Constructor Details
#initialize(klass) ⇒ VarsDSL
Returns a new instance of VarsDSL.
6 7 8 |
# File 'lib/rspec_vars_helper.rb', line 6 def initialize(klass) @klass = klass end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/rspec_vars_helper.rb', line 10 def method_missing(method_name, *args, &block) case method_name when /!$/ @klass.class_eval { let!(:"#{method_name.to_s.sub(/!$/,'')}", &block) } else @klass.class_eval { let(method_name, &block) } end end |