Class: Camille::Rendered
- Inherits:
-
Object
- Object
- Camille::Rendered
- Defined in:
- lib/camille/rendered.rb
Overview
A JSON string that has already passed a type check for the type identified by
fingerprint. Any type will accept a Rendered with a matching fingerprint
without re-checking it, and to_json splices the string verbatim, so a
Rendered can be stored (e.g. in Rails.cache) and placed into a later
response as an opaque, immutable fragment.
Instance Attribute Summary collapse
-
#fingerprint ⇒ Object
readonly
Returns the value of attribute fingerprint.
-
#json ⇒ Object
readonly
Returns the value of attribute json.
Instance Method Summary collapse
-
#initialize(fingerprint, json) ⇒ Rendered
constructor
A new instance of Rendered.
-
#marshal_dump ⇒ Object
Marshal (and therefore the default
Rails.cachecoder) stores only the two strings, so cached entries stay valid across changes to this class's internals. - #marshal_load(array) ⇒ Object
- #to_json(options = nil) ⇒ Object
Constructor Details
#initialize(fingerprint, json) ⇒ Rendered
Returns a new instance of Rendered.
10 11 12 13 |
# File 'lib/camille/rendered.rb', line 10 def initialize fingerprint, json @fingerprint = fingerprint @json = json end |
Instance Attribute Details
#fingerprint ⇒ Object (readonly)
Returns the value of attribute fingerprint.
8 9 10 |
# File 'lib/camille/rendered.rb', line 8 def fingerprint @fingerprint end |
#json ⇒ Object (readonly)
Returns the value of attribute json.
8 9 10 |
# File 'lib/camille/rendered.rb', line 8 def json @json end |
Instance Method Details
#marshal_dump ⇒ Object
Marshal (and therefore the default Rails.cache coder) stores only the two
strings, so cached entries stay valid across changes to this class's
internals.
22 23 24 |
# File 'lib/camille/rendered.rb', line 22 def marshal_dump [@fingerprint, @json] end |
#marshal_load(array) ⇒ Object
26 27 28 |
# File 'lib/camille/rendered.rb', line 26 def marshal_load array @fingerprint, @json = array end |
#to_json(options = nil) ⇒ Object
15 16 17 |
# File 'lib/camille/rendered.rb', line 15 def to_json = nil @json end |