Class: Mincer::Processors::PgJsonDumper

Inherits:
Object
  • Object
show all
Defined in:
lib/mincer/processors/pg_json_dumper.rb

Instance Method Summary collapse

Constructor Details

#initialize(mincer, options = {}) ⇒ PgJsonDumper

Returns a new instance of PgJsonDumper.



5
6
7
# File 'lib/mincer/processors/pg_json_dumper.rb', line 5

def initialize(mincer, options = {})
  @mincer, @args, @relation, @options = mincer, mincer.args, mincer.relation, options
end

Instance Method Details

#applyObject



9
10
11
# File 'lib/mincer/processors/pg_json_dumper.rb', line 9

def apply
  @relation
end

#to_jsonObject



13
14
15
16
17
18
19
# File 'lib/mincer/processors/pg_json_dumper.rb', line 13

def to_json
  if dump_supported?
    Mincer.connection.execute(@options[:root] ? query_with_root(@options[:root]) : query).first['json']
  else
    warn 'To dump data to json with postgres you need to use postgres server version >= 9.2'
  end
end