Method is an object in Ruby, but we need a real method object. Welcome to ActiveMethod!
- Clean scope without module
- High maintainability with tiny method objects
- Make wrting OO easy, then writing OO everywhere
$ bundle add active_methodIt just do what a method do, and nothing else!
classUserincludeActiveMethodactive_method:fooactive_method:bar,MyBaractive_method:build_one,class_method: trueendmoduleUtilactive_method:parse_url,module_function: trueendclassFoo < ActiveMethod::Baseargument:aargument:b,default: 2keyword_argument:ckeyword_argument:d,default: 4defcallputs"a: #{a}, b: #{b}, c: #{c}, d: #{d}"endendUser.new.foo('aa',3,c: 'cc',d: 5)#=> a: aa, b: 3, c: cc, d: 5classUserincludeActiveMethodattr_accessor:nameattr_accessor:fromal_nameactive_method:hiendclassHi < ActiveMethod::Baseonwer:supportdefcallputs"Hi, I'm a #{support.fromal_name}. Please call me #{user.name}"endenduser=User.newuser.name='ActiveMethod'user.fromal_name='method object'user.hi#=> Hi, I'm a method objectc, please call me ActiveMethodbundle install
meval rake # Run test
meval -a rake # Run tests against all Ruby versions and Rails versionsBug reports and pull requests are welcome on GitHub at https://github.com/hoppergee/active_method. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the ActiveMethod project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
