lib/surrogate/hatchling.rb in surrogate-0.6.3 vs lib/surrogate/hatchling.rb in surrogate-0.6.4
- old
+ new
@@ -17,11 +17,13 @@
end
def invoke_method(method_name, args, &block)
invocation = Invocation.new(args, &block)
invoked_methods[method_name] << invocation
- return get_default method_name, invocation, &block unless has_ivar? method_name
+ if setter?(method_name) || !has_ivar?(method_name)
+ return get_default method_name, invocation, &block
+ end
interfaces_must_match! method_name, args
Value.factory(get_ivar method_name).value(method_name)
end
def prepare_method(method_name, args, &block)
@@ -32,9 +34,13 @@
def invocations(method_name)
invoked_methods[method_name]
end
private
+
+ def setter?(method_name)
+ method_name.match(/\w=$/)
+ end
def invoked_methods
@invoked_methods ||= Hash.new do |hash, method_name|
must_know method_name
hash[method_name] = []