class Moonrope::DSL::BaseDSL
Public Class Methods
new(base)
click to toggle source
Initiaize a new BaseDSL
@param base [Moonrope::Base]
# File lib/moonrope/dsl/base_dsl.rb, line 14 def initialize(base) @base = base end
Public Instance Methods
authenticator(name, &block)
click to toggle source
Define a new authenticator
# File lib/moonrope/dsl/base_dsl.rb, line 73 def authenticator(name, &block) authenticator = Moonrope::Authenticator.new(name) dsl = Moonrope::DSL::AuthenticatorDSL.new(authenticator) dsl.instance_eval(&block) if block_given? @base.authenticators[name] = authenticator end
controller(name, &block)
click to toggle source
Define a new controller or append values to an existing controller if it has already been defined.
@param name [Symbol] the name of the controller @yield instance evals the block within the ControllerDSL
# File lib/moonrope/dsl/base_dsl.rb, line 42 def controller(name, &block) existing = @base.controllers.select { |a| a.name == name }.first if existing controller = existing else controller = Moonrope::Controller.new(@base, name) @base.controllers << controller end controller.dsl.instance_eval(&block) if block_given? controller end
helper(name, options = {}, &block)
click to toggle source
Define a new helper in the global namespace
@param name [Symbol] the name of the helper @yield stores the block to execute for the helper
# File lib/moonrope/dsl/base_dsl.rb, line 60 def helper(name, options = {}, &block) if @base.helper(name, nil) raise Moonrope::Errors::HelperAlreadyDefined, "Helper has already been defined with name `#{name}`" end helper_instance = Moonrope::Helper.new(name, nil, options, &block) @base.helpers << helper_instance helper_instance end
structure(name, &block)
click to toggle source
Define a new structure
@param name [Symbol] the name of the structure @yield instance evals the block within the StructureDSL
# File lib/moonrope/dsl/base_dsl.rb, line 24 def structure(name, &block) if existing = @base.structures.select { |s| s.name == name }.first structure = existing else structure = Moonrope::Structure.new(@base, name) @base.structures << structure end structure.dsl.instance_eval(&block) if block_given? structure end