Class: ArbitraryMock::Base
- Inherits:
-
Object
- Object
- ArbitraryMock::Base
- Defined in:
- lib/arbitrary_mock/base.rb
Instance Method Summary collapse
-
#initialize(property_hash = {}) ⇒ Base
constructor
A new instance of Base.
- #method_missing(*args) ⇒ Object
Constructor Details
#initialize(property_hash = {}) ⇒ Base
Returns a new instance of Base.
4 5 6 |
# File 'lib/arbitrary_mock/base.rb', line 4 def initialize(property_hash={}) @property_hash = property_hash end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/arbitrary_mock/base.rb', line 8 def method_missing(*args) method_name = args.first setter_method_match = /(.*)=$/.match(method_name) return @property_hash[method_name] if setter_method_match.nil? setter_method = setter_method_match.captures.first.to_sym @property_hash[setter_method] = args[1] end |