Sha256: 3c9312b326b267c3c8a10bffc2a6bf7153bfa9b7c0bb770f44e65e378ef17bf1

Contents?: true

Size: 923 Bytes

Versions: 12

Compression:

Stored size: 923 Bytes

Contents

require "roar/representer/feature/http_verbs"

module Roar
  # Automatically add accessors for properties and collections. Also mixes in HttpVerbs.
  module Representer
    module Feature
      module Client
        include HttpVerbs

        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

        def before_serialize(options={})
          super({:links => false}.merge!(options))
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
roar-0.12.0 lib/roar/representer/feature/client.rb
roar-0.11.19 lib/roar/representer/feature/client.rb
roar-0.11.18 lib/roar/representer/feature/client.rb
roar-0.11.17 lib/roar/representer/feature/client.rb
roar-0.11.16 lib/roar/representer/feature/client.rb
roar-0.11.15 lib/roar/representer/feature/client.rb
roar-0.11.14 lib/roar/representer/feature/client.rb
roar-0.11.13 lib/roar/representer/feature/client.rb
roar-0.11.12 lib/roar/representer/feature/client.rb
roar-0.11.11 lib/roar/representer/feature/client.rb
roar-0.11.10 lib/roar/representer/feature/client.rb
roar-0.11.9 lib/roar/representer/feature/client.rb