class GlueGun::ConfigBuilder

Attributes

operations[R]

Public Class Methods

new(context) click to toggle source
# File lib/glue_gun/config_builder.rb, line 5
def initialize(context)
  @context = context
end

Public Instance Methods

cached_command(*args) { || ... } click to toggle source
# File lib/glue_gun/config_builder.rb, line 30
def cached_command(*args)
  if cached_value = deferred_commands.detect {|command| command == args }
    cached_value
  else
    command = yield
    deferred_commands << command
    command
  end
end
configure!() click to toggle source
# File lib/glue_gun/config_builder.rb, line 26
def configure!
  deferred_commands.each { |commands| commands.call }
end
method_missing(method_name, *args, &block) click to toggle source
Calls superclass method
# File lib/glue_gun/config_builder.rb, line 9
def method_missing(method_name, *args, &block)
  command_name = command_name_for_method(method_name)
  if Commands.const_defined?(command_name)
    command_class = Commands.const_get(command_name)
    command_class.new(self, *args, &block)
  else
    super
  end
end
respond_to_missing?(method_name, include_private=false) click to toggle source
Calls superclass method
# File lib/glue_gun/config_builder.rb, line 19
def respond_to_missing?(method_name, include_private=false)
  command_name = command_name_for_method(method_name)
  Commands.const_defined?(command_name) || super
rescue NameError
  super
end

Private Instance Methods

command_name_for_method(method_name) click to toggle source
# File lib/glue_gun/config_builder.rb, line 42
def command_name_for_method(method_name)
  method_name.to_s.gsub(/(?:^|_)([a-z])/) { $1.upcase }
end
deferred_commands() click to toggle source
# File lib/glue_gun/config_builder.rb, line 46
def deferred_commands
  @deferred_commands ||= []
end