Sha256: 782fa88bdc59d9c4699d3c95d46d9c22ea38b8ffd573dadc37c00e48f15710ad

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

include ERBh

ERBh.define_method(:i) do |obj|
  if obj.nil? or (obj.respond_to?(:empty?) and obj.empty?)
    @_erbout.sub!(/,\s*\z/, '')
    ''
  else
    obj.modern_inspect_without_brace
  end
end

ERBh.define_method(:add_index) do |table_name, column_name, options|
  if options[:length].is_a?(Hash)
    options[:length] = options[:length].symbolize_keys
  end

  @_erbout.sub!(/\bend\s*\z/, '')

  # XXX:
  if not condition('5.0') and options[:using] == :btree
    options.delete(:using)
  end

  # XXX:
  if options.has_key?(:force_using)
    options[:using] = options.delete(:force_using)
  end

  <<-EOS
      t.index #{column_name.inspect}, #{options.modern_inspect_without_brace}
    end
  EOS
end

ERBh.define_method(:unsigned) do |value, *conds|
  if condition(*conds)
    {unsigned: value}
  else
    {}
  end
end

ERBh.define_method(:limit) do |value, *conds|
  if condition(*conds)
    {limit: value}
  else
    {}
  end
end

ERBh.define_method(:cond) do |conds, m, e = nil|
  if condition(*Array(conds))
    m
  else
    e || (m.class.new rescue nil)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ridgepole-0.7.0.alpha spec/erb_helper.rb