Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use Hash#fetch for compiler options

  • Loading branch information...
commit 559f8ca97edfe9e2b7ba5870b7a052a3d2099f81 1 parent eed9685
@tanelj tanelj authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/json_builder/compiler.rb
View
6 lib/json_builder/compiler.rb
@@ -44,9 +44,9 @@ def generate(*args, &block)
# Returns instance of JSONBuilder::Compiler.
def initialize(options={})
@_members = []
- @_scope = options[:scope]
- @_callback = options.has_key?(:callback) ? options[:callback] : true
- @_pretty_print = options.has_key?(:pretty) ? options[:pretty] : false
+ @_scope = options.fetch(:scope, nil)
+ @_callback = options.fetch(:callback, true)
+ @_pretty_print = options.fetch(:pretty, false)
# Only copy instance variables if there is a scope and presence of Rails
copy_instance_variables_from(@_scope) if @_scope
Please sign in to comment.
Something went wrong with that request. Please try again.