module GoldenFleece::Utility

Constants

FALSE_VALUES

Public Instance Methods

build_json_path(parent_path, key_name) click to toggle source
# File lib/golden_fleece/utility.rb, line 5
def build_json_path(parent_path, key_name)
  "#{parent_path}#{'/' unless parent_path =~ /\/$/}#{key_name}"
end
cast_boolean(value) click to toggle source

Copied from ActiveModel::Type::Boolean github.com/rails/rails/blob/master/activemodel/lib/active_model/type/boolean.rb

# File lib/golden_fleece/utility.rb, line 15
def cast_boolean(value)
  if value == "" || value == nil
    nil
  else
    !FALSE_VALUES.include?(value)
  end
end
deep_stringify_keys(hash) click to toggle source
# File lib/golden_fleece/utility.rb, line 23
def deep_stringify_keys(hash)
  hash.reduce({}) { |memo, (key, value)|
    memo[key.to_s] = value.is_a?(Hash) ? deep_stringify_keys(value) : value
    memo
  }
end
error_suffix(attribute, path) click to toggle source
# File lib/golden_fleece/utility.rb, line 9
def error_suffix(attribute, path)
  "'#{path}' on column '#{attribute}'"
end