Class: Template::Handlers::JsonifyBuilder

Inherits:
Template::Handler
  • Object
show all
Includes:
Compilable
Defined in:
lib/jsonify-rails/jsonify_builder.rb,
lib/jsonify-rails/jsonify_builder.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(template) ⇒ Object



29
30
31
32
33
# File 'lib/jsonify-rails/jsonify_builder.rb', line 29

def self.call(template)
  "json = ::Jsonify::Builder.new(:format => :#{jsonify_format});" +
    template.source +
  ";json.compile!;"
end

Instance Method Details

#compile(template) ⇒ Object



10
11
12
13
14
# File 'lib/jsonify-rails/jsonify_builder.rb', line 10

def compile(template)
  "json = ::Jsonify::Builder.new(:format => :#{jsonify_format});" +
    template.source +
  ";json.compile!;"
end

#default_formatObject



25
26
27
# File 'lib/jsonify-rails/jsonify_builder.rb', line 25

def default_format
  Mime::JSON
end