Sha256: 0d325bdc16386a9d399d1d2da72cac0689fb0ed988e8712ccbff47728869deeb

Contents?: true

Size: 529 Bytes

Versions: 5

Compression:

Stored size: 529 Bytes

Contents

module GrapeResource
  module Configuration
    def setup
      yield self
    end

    def define_setting(name, default = nil)
     class_variable_set("@@#{name}", default)

     define_class_method "#{name}=" do |value|
     class_variable_set("@@#{name}", value)
    end

    define_class_method name do
     class_variable_get("@@#{name}")
     end
    end

    private

    def define_class_method(name, &block)
      (class << self; self; end).instance_eval do
        define_method name, &block
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
grape_resource-0.1.11 lib/grape_resource/configuration.rb
grape_resource-0.1.10 lib/grape_resource/configuration.rb
grape_resource-0.1.6 lib/grape_resource/configuration.rb
grape_resource-0.1.5 lib/grape_resource/configuration.rb
grape_resource-0.1.3 lib/grape_resource/configuration.rb