Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Actually, ivar assignment/caching is unnecessary

  • Loading branch information...
commit 6732706adfa455e0935aca4cfff9454b526f25b8 1 parent 6fb7b3f
@sferik authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/twitter/base.rb
View
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
dkubb added a note

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

@attributes[attribute.to_s]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
end
- RUBY
+ end
end
end
@dkubb

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

@attributes[attribute.to_s]
Please sign in to comment.
Something went wrong with that request. Please try again.