Sha256: a15b5c1058269f99c46be9f942f2dc2d6779ded528a8510dbb986c249ff39e1e

Contents?: true

Size: 993 Bytes

Versions: 4

Compression:

Stored size: 993 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
      options[:user_options] ||= {}
      options[:user_options][:links] ||= false

      super(options)
    end

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

      super(options)
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/roar-1.2.0/lib/roar/client.rb
roar-1.2.0 lib/roar/client.rb
roar-1.1.1 lib/roar/client.rb
roar-1.1.0 lib/roar/client.rb