Last active
August 29, 2015 14:16
-
-
Save robertzk/fb542d01c43e96225a26 to your computer and use it in GitHub Desktop.
unused Ruby ideas
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
mattr_accessor - https://github.com/rails/rails/blob/master/railties/lib/rails/generators.rb#L24 | |
levenshtein_distance for suggestions - https://github.com/rails/rails/blob/master/railties/lib/rails/generators.rb#L160 | |
# https://github.com/rails/rails/blob/master/railties/lib/rails/generators.rb#L258 | |
# Rescue from LoadError | |
# https://github.com/rails/rails/blob/master/railties/lib/rails/generators.rb#L334 | |
[1] pry(main)> ["a","b","c","d"].to_sentence(last_word_connector: " and ") | |
=> "a, b, c and d" | |
# https://github.com/rails/rails/blob/master/railties/lib/rails/generators.rb#L162 | |
class << (@@properties = []) | |
# https://github.com/rails/rails/blob/master/railties/lib/rails/info.rb#L9 | |
# [8] pry(#<Array>)> [["a", 1], ["b", 2]].assoc("b") | |
=> ["b", 2] | |
# [9] pry(#<Array>)> "%-10s %s" % ["a", "b"] | |
=> "a b" | |
# https://github.com/rails/rails/blob/master/railties/lib/rails/info.rb#L32 | |
# [20] pry(#<Array>)> 'boo'.tap do |bee| | |
# [20] pry(#<Array>)* bee << "bee" | |
# [20] pry(#<Array>)* end << "bop" | |
=> "boobeebop" | |
# Hash#fetch | |
# irb(main):025:0> {a:nil,b:1}.fetch(:a, 1) | |
=> nil | |
# Dir.chdir { .. } is equivalent to "perform within directory" | |
# https://github.com/rails/rails/blob/master/railties/lib/rails/paths.rb#L187 | |
ActiveSupport::FileUpdateChecker.new(*paths) { ... } | |
# https://github.com/rails/rails/blob/master/railties/lib/rails/application/routes_reloader.rb#L26 | |
# https://github.com/rails/rails/blob/master/railties/lib/rails/engine/configuration.rb#L56 | |
# Nested initializers! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/rails/rails/tree/master/activesupport/lib/active_support/core_ext
Core extensions to Ruby classes.