Skip to content
Browse files

Actually, ivar assignment/caching is unnecessary

  • Loading branch information...
1 parent 6fb7b3f commit 6732706adfa455e0935aca4cfff9454b526f25b8 @sferik committed Oct 18, 2011
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/twitter/base.rb
8 lib/twitter/base.rb
@@ -3,11 +3,11 @@ class Base
def self.lazy_attr_reader(*attributes)
attributes.each do |attribute|
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
- def #{attribute}
- @#{attribute} ||= @attributes[#{attribute.to_s.inspect}]
+ class_eval do
+ define_method attribute do
+ instance_variable_get("@attributes")[attribute.to_s]
dkubb added a note Oct 19, 2011

The instance variable is static here, so there's no need to use instance_variable_get, you can just replace this line with:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ end

0 comments on commit 6732706

Please sign in to comment.
Something went wrong with that request. Please try again.