Created
September 25, 2013 19:16
-
-
Save Olefine/6704596 to your computer and use it in GitHub Desktop.
string
This file contains 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
class MyString < String | |
@@array_of_strings ||= [] | |
def self.new(str) | |
@@array_of_strings << super(str) | |
p @@array_of_strings | |
end | |
private | |
def self.all_strings | |
p @@array_of_strings | |
end | |
end | |
class Store | |
def self.all_strings | |
MyString.send(:all_strings) | |
end | |
end | |
p Store.all_strings.include? MyString.new("egor") | |
# [] | |
# ["egor"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment