Sha256: 4330a4d4af9fa2c307558c8aa85bdba984287ac88e182cb7693312d80105176b

Contents?: true

Size: 856 Bytes

Versions: 4

Compression:

Stored size: 856 Bytes

Contents

require "roar/http_verbs"

module Roar

  # Mix in HttpVerbs. 
  module Client
    include HttpVerbs

    # Add accessors for properties and collections to modules.
    def self.extended(base)
      base.instance_eval do
        representable_attrs.each do |attr|
          name = attr.name
          next if name == "links" # ignore hyperlinks.

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

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

    def to_hash(options={})
      options[:links] ||= false
      super(options)
    end

    def to_xml(options={}) # sorry, but i'm not even sure if anyone uses this module.
      options[:links] ||= false
      super(options)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
roar-1.0.4 lib/roar/client.rb
roar-1.0.3 lib/roar/client.rb
roar-1.0.2 lib/roar/client.rb
roar-1.0.1 lib/roar/client.rb