Created
August 30, 2013 05:54
-
-
Save jjasonclark/6386688 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://rubygems.org" | |
gem 'pry' | |
gem "scoped_attr_accessor", github: "dbrady/scoped_attr_accessor", branch: "master" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GIT | |
remote: git://github.com/dbrady/scoped_attr_accessor.git | |
revision: 100d1417ecbbda621e7a23715798f31f16ddb8d2 | |
branch: master | |
specs: | |
scoped_attr_accessor (1.0.3) | |
GEM | |
remote: https://rubygems.org/ | |
specs: | |
coderay (1.0.9) | |
method_source (0.8.2) | |
pry (0.9.12.2) | |
coderay (~> 1.0.5) | |
method_source (~> 0.8) | |
slop (~> 3.4) | |
slop (3.4.6) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
pry | |
scoped_attr_accessor! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'scoped_attr_accessor' | |
require 'pry' | |
class With | |
extend ScopedAttrAccessor | |
attr_reader :foobar | |
private_attr_writer :foobar | |
def initialize | |
@foobar = :from_with_init | |
end | |
end | |
class Without | |
attr_reader :foobar | |
def initialize | |
@foobar = :from_without_init | |
end | |
private | |
def foobar=(arg); @foobar = arg; end | |
end | |
many_methods = With.new | |
few_methods = Without.new | |
puts "Using ScopedAttrAccessor: method count = #{many_methods.methods.count}" | |
puts "Witout ScopedAttrAccessor: method count = #{few_methods.methods.count}" | |
binding.pry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment