Sha256: 493243b08416804489c3da174dd0ac38d8c079c17e84fca6bbf108ff51631102
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
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 def string_like?(value) value.is_a?(Symbol) || value.is_a?(String) end def extract_position_from_options(array, options) position = options.extract!(:before, :after) if position[:before] array.index {|c| c.name.to_sym == position[:before].to_sym } elsif position[:after] array.index {|c| c.name.to_sym == position[:after].to_sym } + 1 else -1 end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
datagrid-0.9.2 | lib/datagrid/utils.rb |