Sha256: 74b1bb03a980268e924f0bcd86437548be07d314db6486b3a78f2d87df292944

Contents?: true

Size: 705 Bytes

Versions: 4

Compression:

Stored size: 705 Bytes

Contents

require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/hash_with_indifferent_access'

module Valle
  module Configuration

    mattr_accessor :options

    self.options = {
      enabled: true, # gem is enabled by default
      models: nil, # selects all AR models by default
      attributes: ActiveSupport::HashWithIndifferentAccess.new, # adds validators to all attributes by default
    }

    def configure
      yield self
    end

    def enabled=(value)
      self.options[:enabled] = value
    end

    def models=(collection)
      self.options[:models] = collection
    end

    def attributes=(mapping)
      self.options[:attributes] = mapping
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
valle-0.2.3 lib/valle/configuration.rb
valle-0.2.2 lib/valle/configuration.rb
valle-0.2.1 lib/valle/configuration.rb
valle-0.2.0 lib/valle/configuration.rb