Sha256: 65802d1be7ec9f1dde2a9dbbdde8e86635db819123d9fa03dd0be71084561d97
Contents?: true
Size: 1.27 KB
Versions: 4
Compression:
Stored size: 1.27 KB
Contents
require 'roar/representer' require 'roar/hypermedia' require 'representable/json' module Roar module JSON def self.included(base) base.class_eval do include Representer include Representable::JSON extend ClassMethods include InstanceMethods # otherwise Representable overrides our #to_json. end end module InstanceMethods def from_json(document, options={}) document = '{}' if document.nil? or document.empty? super end # Generic entry-point for rendering. def serialize(*args) to_json(*args) end def deserialize(*args) from_json(*args) end end module ClassMethods # TODO: move to instance method, or remove? def links_definition_options # FIXME: this doesn't belong into the generic JSON representer. { class: Hypermedia::Hyperlink, decorator: HyperlinkDecorator, collection: true, exec_context: :decorator } end end require "representable/json/hash" # Represents a hyperlink in standard roar+json hash representation. class HyperlinkDecorator < Representable::Decorator include Representable::JSON::Hash end end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
blacklight-spotlight-3.6.0.beta8 | vendor/bundle/ruby/3.2.0/gems/roar-1.2.0/lib/roar/json.rb |
roar-1.2.0 | lib/roar/json.rb |
roar-1.1.1 | lib/roar/json.rb |
roar-1.1.0 | lib/roar/json.rb |