Sha256: f477f846bcb96e3899118183f4fe183ef0eecd8ad6cf06151a737f7b221e4bfe
Contents?: true
Size: 1.58 KB
Versions: 9
Compression:
Stored size: 1.58 KB
Contents
# Ruby extensions **ruby_ext** is a collection of various utility classes and standard library extensions for the Ruby language. ## must - assertion tool, kind of RSpec assertions in runtime code 1.must_be.in 1..2 "a".must_be.in 'a', 'b', 'c' key.must_be.a String value.must_not_be.nil must_be.never_called a.must_be == b ## inherit - combines include & extend in one Do you remember this *def self.included(base) ... end* hack? You don't need it anymore. module Feature def cool_method; end class_methods do def cool_class_method; end end end class TheClass inherit Feature end TheClass.new.cool_method TheClass.cool_class_method ## cache_method & synchronize_method def complex_calculation 2 * 2 end cache_method :complex_calculation def money_transfer amount @from -= amount @to += amount end synchronize_method :money_transfer ## OpenConstructor - adds mass assignment to any class class TheClass include OpenConstructor attr_accessor :a, :b end o = TheClass.new.set a: 'a', b: 'b' o.a => 'a' o.to_hash => {a: 'a', b: 'b'} ## More These are just a small part of all handy methods and extensions, for more details please go to specs. # Usage $ sudo gem install ruby_ext require 'ruby_ext' Copyright (c) Alexey Petrushin [http://4ire.net](http://4ire.net), released under the MIT license. # TODO - config.development{} should raise 'invalid usage' [ioc]: http://en.wikipedia.org/wiki/Inversion_of_control
Version data entries
9 entries across 9 versions & 1 rubygems