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!
class User
  include ActiveMethod
  active_method :foo
  active_method :bar, MyBar
  active_method :build_one, class_method: true
end
module Util
  active_method :parse_url, module_function: true
endclass Foo < ActiveMethod::Base
  argument :a
  argument :b, default: 2
  keyword_argument :c
  keyword_argument :d, default: 4
  def call
    puts "a: #{a}, b: #{b}, c: #{c}, d: #{d}"
  end
end
User.new.foo('aa', 3, c: 'cc', d: 5)
#=> a: aa, b: 3, c: cc, d: 5class User
  include ActiveMethod
  attr_accessor :name
  attr_accessor :fromal_name
  active_method :hi
end
class Hi < ActiveMethod::Base
  onwer :support
  def call
    puts "Hi, I'm a #{support.fromal_name}. Please call me #{user.name}"
  end
end
user = User.new
user.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.
