Skip to content

Instantly share code, notes, and snippets.

@Olefine
Created September 25, 2013 19:16
Show Gist options
  • Save Olefine/6704596 to your computer and use it in GitHub Desktop.
Save Olefine/6704596 to your computer and use it in GitHub Desktop.
string
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