Sha256: 520aeda948b79af5e82610d8d6d3e2d1d03edaa93d30e19064ecfba4a19f977f

Contents?: true

Size: 774 Bytes

Versions: 8

Compression:

Stored size: 774 Bytes

Contents

module Datagrid
  module Utils
    class << self


      TRUTH = [true, 1, "1", "true", "yes", "on"]

      def booleanize(value)
        TRUTH.include?(value)
      end

      def warn_once(message)
        @warnings ||= {}
        if @warnings[message] 
          false
        else
          warn message
          @warnings[message] = true
        end
      end

      def add_html_classes(options, *classes)
        options = options.clone
        options[:class] ||= ""
        if options[:class].is_a?(Array)
          options[:class] += classes
        else
          # suppose that it is a String
          options[:class] += " " unless options[:class].blank?
          options[:class] += classes.join(" ")
        end
        options
      end


    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
datagrid-0.9.0 lib/datagrid/utils.rb
datagrid-0.8.4 lib/datagrid/utils.rb
datagrid-0.8.3 lib/datagrid/utils.rb
datagrid-0.8.2 lib/datagrid/utils.rb
datagrid-0.8.1 lib/datagrid/utils.rb
datagrid-0.8.0 lib/datagrid/utils.rb
datagrid-0.7.1 lib/datagrid/utils.rb
datagrid-0.7.0 lib/datagrid/utils.rb