module ModablesDSL::DSL
Public Class Methods
arguments(&block)
click to toggle source
The arguments block is invoked inside section block to further build the hash.
# File lib/modables_dsl/dsl/core.rb, line 19 def self.arguments &block build = ModablesDSL::DSL::Args.new build.instance_eval(&block) build.args_h end
encode_json()
click to toggle source
# File lib/modables_dsl/dsl/core.rb, line 25 def self.encode_json ActiveSupport::JSON.encode(@data) end
method_missing(meth, *args, &block)
click to toggle source
There are a number of sections supported, account for all of them.
# File lib/modables_dsl/dsl/core.rb, line 14 def self.method_missing meth, *args, &block self.section(*args.unshift(meth), &block) end
morb() { || ... }
click to toggle source
# File lib/modables_dsl/dsl/core.rb, line 29 def self.morb yield self.encode_json end
section(*scaffold, &block)
click to toggle source
The section scaffolding is built by reading an array and creating a hash with each element as a nested key of the previous element.
# File lib/modables_dsl/dsl/core.rb, line 6 def self.section *scaffold, &block @data = Hash.new if @data.nil? config_block = scaffold.reverse.inject(self.arguments(&block)) { |k, v| { v => k } } @data.deep_merge!(config_block) end