Module: Roar::Representer::Feature::Client

Includes:
HttpVerbs
Defined in:
lib/roar/representer/feature/client.rb

Instance Attribute Summary

Attributes included from HttpVerbs

#transport_engine

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HttpVerbs

#delete, #get, included, #patch, #post, #put

Class Method Details

.extended(base) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/roar/representer/feature/client.rb', line 10

def self.extended(base)
  base.instance_eval do
    representable_attrs.each do |attr|
      next unless attr.instance_of? Representable::Definition # ignore hyperlinks etc for now.
      name = attr.name

      # TODO: could anyone please make this better?
      instance_eval %Q{
        def #{name}=(v)
          @#{name} = v
        end

        def #{name}
          @#{name}
        end
      }
    end
  end
end

Instance Method Details

#before_serialize(options = {}) ⇒ Object

DISCUSS: should we just override #serialize here? otherwise if you later include Hypermedia, it’ll run before that method.



31
32
33
34
35
# File 'lib/roar/representer/feature/client.rb', line 31

def before_serialize(options={})
  options[:links] ||= false

  super(options)
end