Module: PgHero::HomeHelper

Defined in:
app/helpers/pg_hero/home_helper.rb

Instance Method Summary collapse

Instance Method Details

#pghero_js_var(name, value) ⇒ Object



15
16
17
# File 'app/helpers/pg_hero/home_helper.rb', line 15

def pghero_js_var(name, value)
  "var #{name} = #{json_escape(value.to_json(root: false))};".html_safe
end

#pghero_pretty_ident(table, schema: nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/pg_hero/home_helper.rb', line 3

def pghero_pretty_ident(table, schema: nil)
  ident = table
  if schema && schema != "public"
    ident = "#{schema}.#{table}"
  end
  if ident =~ /\A[a-z0-9_]+\z/
    ident
  else
    @database.quote_ident(ident)
  end
end

#pghero_remove_index(query) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/pg_hero/home_helper.rb', line 19

def pghero_remove_index(query)
  if query[:columns]
    columns = query[:columns].map(&:to_sym)
    columns = columns.first if columns.size == 1
  end
  ret = String.new("remove_index #{query[:table].to_sym.inspect}")
  ret << ", name: #{(query[:name] || query[:index]).to_s.inspect}"
  ret << ", column: #{columns.inspect}" if columns
  ret
end