Relocate DslHelper from root namespace to under AASM namespace

`DslHelper` is a module for AASM and should not be located in the root
namespace.
This commit is contained in:
Yuji Hanamura 2020-10-10 22:48:20 +09:00 committed by Anil Kumar Maurya
parent 42b66b8377
commit ccdb2172f8
3 changed files with 26 additions and 24 deletions

View File

@ -2,7 +2,7 @@
module AASM::Core
class Event
include DslHelper
include AASM::DslHelper
attr_reader :name, :state_machine, :options

View File

@ -2,7 +2,7 @@
module AASM::Core
class Transition
include DslHelper
include AASM::DslHelper
attr_reader :from, :to, :event, :opts, :failures
alias_method :options, :opts

View File

@ -1,30 +1,32 @@
module DslHelper
module AASM
module DslHelper
class Proxy
attr_accessor :options
class Proxy
attr_accessor :options
def initialize(options, valid_keys, source)
@valid_keys = valid_keys
@source = source
def initialize(options, valid_keys, source)
@valid_keys = valid_keys
@source = source
@options = options
end
@options = options
end
def method_missing(name, *args, &block)
if @valid_keys.include?(name)
options[name] = Array(options[name])
options[name] << block if block
options[name] += Array(args)
else
@source.send name, *args, &block
def method_missing(name, *args, &block)
if @valid_keys.include?(name)
options[name] = Array(options[name])
options[name] << block if block
options[name] += Array(args)
else
@source.send name, *args, &block
end
end
end
end
def add_options_from_dsl(options, valid_keys, &block)
proxy = Proxy.new(options, valid_keys, self)
proxy.instance_eval(&block)
proxy.options
end
def add_options_from_dsl(options, valid_keys, &block)
proxy = Proxy.new(options, valid_keys, self)
proxy.instance_eval(&block)
proxy.options
end
end
end
end