Sha256: 87630b2dec0a3f5de45d5e8285c044c118f20a56601a4d91d29e5fc15b8dea0e

Contents?: true

Size: 750 Bytes

Versions: 5

Compression:

Stored size: 750 Bytes

Contents

module HungryForm
  class Configuration
    attr_accessor :views_prefix

    def initialize
      @views_prefix = 'hungryform'

      init_element_default_attributes
    end

    private

    def init_element_default_attributes
      @elements_default_attributes = {}

      HungryForm::Elements.all_classes.each do |klass|
        klass_name = klass.to_s.underscore.to_sym
        @elements_default_attributes[klass_name] = {}

        # Assign a default attribute to an element
        define_singleton_method klass_name do |attributes = {}|
          if attributes.any?
            @elements_default_attributes[klass_name].merge!(attributes)
          end

          @elements_default_attributes[klass_name]
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hungryform-0.0.10 lib/hungryform/configuration.rb
hungryform-0.0.9 lib/hungryform/configuration.rb
hungryform-0.0.8 lib/hungryform/configuration.rb
hungryform-0.0.7 lib/hungryform/configuration.rb
hungryform-0.0.6 lib/hungryform/configuration.rb