Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relocate DslHelper from root namespace to under AASM namespace
`DslHelper` is a module for AASM and should not be located in the root namespace.
- Loading branch information
1 parent
42b66b8
commit ccdb217
Showing
3 changed files
with
26 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |