Sha256: 853a0ecab614252bd7f8a86051de885db9aa1202ce6b496f203cd2f0602d4d93

Contents?: true

Size: 655 Bytes

Versions: 5

Compression:

Stored size: 655 Bytes

Contents

module TableCloth
  class Configuration
    ELEMENT_OPTIONS = %w(table thead th tbody tr td).map(&:to_sym)

    GENERAL_OPTIONS = %w(alternating_rows).map(&:to_sym)
    attr_accessor *GENERAL_OPTIONS

    ELEMENT_OPTIONS.each do |option|
      class_eval <<-OPTION, __FILE__, __LINE__+1
        def #{option}
          @#{option}_option ||= ActiveSupport::OrderedOptions.new
        end
      OPTION
    end

    class << self
      def configure(&block)
        yield TableCloth.config
      end
    end

    def config_for(type)
      value = send(type)
      value.respond_to?(:to_hash) ? value.to_hash : value
    end
    alias [] config_for
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
table_cloth-0.4.3 lib/table_cloth/configuration.rb
table_cloth-0.4.2 lib/table_cloth/configuration.rb
table_cloth-0.4.1 lib/table_cloth/configuration.rb
table_cloth-0.4.0 lib/table_cloth/configuration.rb
table_cloth-0.3.2 lib/table_cloth/configuration.rb