Skip to content

Commit

Permalink
Fix a test and optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
lsegal committed Sep 3, 2024
1 parent 40cc276 commit b127c8f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/yard/open_struct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ def method_missing(name, *args)
if name.to_s.end_with?('=')
varname = name.to_s[0..-2].to_sym
__cache_lookup__(varname)
self[varname] = args.first
send(name, args.first)
else
__cache_lookup__(name)
self[name]
send(name)
end
end

Expand Down Expand Up @@ -60,7 +60,7 @@ def __cache_lookup__(name)
key = name.to_sym.inspect
instance_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{name}; @table[#{key}]; end
(class << self; self; end).define_method("#{name}=") { |v| @table[#{key}] = v }
def #{name.to_s.sub('?','_')}=(v); @table[#{key}] = v; end unless #{key}.to_s.include?('?')
RUBY
end
end
Expand Down

0 comments on commit b127c8f

Please sign in to comment.