Sha256: 746b3e2fa348cb97b02c11c5c9a0a6144df5568f5126be97b59b1011ac027375

Contents?: true

Size: 777 Bytes

Versions: 9

Compression:

Stored size: 777 Bytes

Contents

module HasManyTranslations
  
  module Configuration
    def configure
      yield Configuration
    end

    class << self
      # Simply stores a hash of options given to the +configure+ block.
      def options
        @options ||= {}
      end

      # If given a setter method name, will assign the first argument to the +options+ hash with
      # the method name (sans "=") as the key. If given a getter method name, will attempt to
      # a value from the +options+ hash for that key. If the key doesn't exist, defers to +super+.
      def method_missing(symbol, *args)
        if (method = symbol.to_s).sub!(/\=$/, '')
          options[method.to_sym] = args.first
        else
          options.fetch(method.to_sym, super)
        end
      end
    end 
  end
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
has_many_translations-0.4.6 lib/has_many_translations/configuration.rb
has_many_translations-0.4.5 lib/has_many_translations/configuration.rb
has_many_translations-0.4.4 lib/has_many_translations/configuration.rb
has_many_translations-0.4.3 lib/has_many_translations/configuration.rb
has_many_translations-0.3.8 lib/has_many_translations/configuration.rb
has_many_translations-0.3.7 lib/has_many_translations/configuration.rb
has_many_translations-0.3.6 lib/has_many_translations/configuration.rb
has_many_translations-0.3.4 lib/has_many_translations/configuration.rb
has_many_translations-0.3.3 lib/has_many_translations/configuration.rb