Sha256: bde88f0d2729dffa3cbdd743e5f0ba55ad7f4259a96c3f02dee4b75b9ec4343a

Contents?: true

Size: 843 Bytes

Versions: 4

Compression:

Stored size: 843 Bytes

Contents

module Guts
  # Configuration for Guts
  # @return [Object] returns configuration
  def self.configuration
    @configuration ||= Configuration.new
  end

  # Defining configuration through block format
  # @yield [configuration] passes current configuration into block
  def self.configure
    yield configuration
  end
  
  # Configuration class for Guts
  class Configuration
    # Getter and setter method for configuration
    # so that there is not a set amount of configs
    # @param [String] name the config name
    # @param [Array] args list of args (used for setting)
    # @return the configuration requested
    def method_missing(name, *args)
      name = name.to_s

      if name =~ (/=$/)
        instance_variable_set "@#{name.chop}", args.first
      else
        instance_variable_get "@#{name}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
guts-1.0.8 lib/guts/configuration.rb
guts-1.0.7 lib/guts/configuration.rb
guts-1.0.5 lib/guts/configuration.rb
guts-1.0.3 lib/guts/configuration.rb