Module: Jinx::Collection

Defined in:
lib/jinx/json/collection.rb

Instance Method Summary collapse

Instance Method Details

#to_json(state = nil) ⇒ String

Adds JSON serialization to collections.

Parameters:

  • state (State, Hash, nil) (defaults to: nil)

    the JSON state or serialization options

Returns:

  • (String)

    the JSON representation of this Resource



10
11
12
13
14
# File 'lib/jinx/json/collection.rb', line 10

def to_json(state=nil)
  # Make a new State from the options if this is a top-level call.
  state = JSON::State.for(state) unless JSON::State === state
  to_a.to_json(state)
end