Module: Supa::Representable::InstanceMethods

Defined in:
lib/supa/representable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#representeeObject (readonly)

Returns the value of attribute representee.



23
24
25
# File 'lib/supa/representable.rb', line 23

def representee
  @representee
end

Instance Method Details

#initialize(representee) ⇒ Object



9
10
11
# File 'lib/supa/representable.rb', line 9

def initialize(representee)
  @representee = representee
end

#to_hashObject



13
14
15
16
17
# 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_jsonObject



19
20
21
# File 'lib/supa/representable.rb', line 19

def to_json
  to_hash.to_json
end