Class: PersonalWordlist::DSL::Partial
- Inherits:
-
Object
- Object
- PersonalWordlist::DSL::Partial
- Defined in:
- lib/personal_wordlist/dsl/partial.rb
Overview
Evaluate of methods in ‘partial` blocks
Instance Method Summary collapse
-
#initialize(personal_data, block, arg) ⇒ Partial
constructor
A new instance of Partial.
-
#method_missing(name) ⇒ Object
Map unknown methods to known keys of the input hash.
- #run! ⇒ Object
Constructor Details
#initialize(personal_data, block, arg) ⇒ Partial
5 6 7 8 9 10 |
# File 'lib/personal_wordlist/dsl/partial.rb', line 5 def initialize(personal_data, block, arg) fail ArgumentError if arg && block @block = block @personal_data = personal_data @arg = arg end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
Map unknown methods to known keys of the input hash
18 19 20 21 |
# File 'lib/personal_wordlist/dsl/partial.rb', line 18 def method_missing(name) return @personal_data[name.to_sym] if @personal_data.key?(name) fail NoMethodError end |
Instance Method Details
#run! ⇒ Object
12 13 14 15 |
# File 'lib/personal_wordlist/dsl/partial.rb', line 12 def run! @block = proc { @arg } if @arg # For string args instance_eval(&@block) end |