module Supa::Representable::InstanceMethods
Attributes
representee[R]
Public Class Methods
new(representee)
click to toggle source
# File lib/supa/representable.rb, line 9 def initialize(representee) @representee = representee end
Public Instance Methods
to_hash()
click to toggle source
# File lib/supa/representable.rb, line 13 def to_hash Supa::Builder.new(representee, representer: self, tree: {}).tap do |builder| builder.instance_exec(&self.class.definition) end.to_hash end
to_json()
click to toggle source
# File lib/supa/representable.rb, line 19 def to_json Oj.dump(to_hash, mode: :strict) end