arr.select.with_index { |e, i| e == i+1 }.size == arr.size
Полезен, когда нужно сделать метод модуля
module X
extend self
def x
pp 'hello'
end
end
[2] pry(main)> X.x
"hello"
module Y
def y
pp 'hi'
end
end
[4] pry(main)> Y.y
NoMethodError: private method `y' called for Y:Module
from (pry):13:in `__pry__'
require 'ostruct'
x = {email: {value: 'me@ya.ru'}}
JSON.parse x.to_json, object_class: OpenStruct
bundle config set without 'production'
User.first.method(:myCustomMethod).source_location
=> ["/Users/mikeappell/Development/demo/app/models/concerns/demoable.rb", 53]