Sha256: 3e5784dc3eb75f1d4b0d9bc6cc51deb1a52d8a779ae79b3656cd762b3d351acc

Contents?: true

Size: 712 Bytes

Versions: 3

Compression:

Stored size: 712 Bytes

Contents

# NOTE:
#  Make a JSON Resource Descriptor (JRD) gem as separate one and use it as superclass?

module WebFinger
  class Response < ActiveSupport::HashWithIndifferentAccess
    def initialize(jrd)
      replace jrd
    end

    [:subject, :aliases, :properties, :links].each do |method|
      define_method method do
        self[method]
      end
    end

    def link_for(rel)
      links.detect do |link|
        link[:rel] == rel
      end
    end

    class << self
      # NOTE: Ugly hack to avoid this ActiveSupport 4.0 bug.
      #  https://github.com/rails/rails/issues/11087
      def new_from_hash_copying_default(hash)
        superclass.new_from_hash_copying_default hash
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
webfinger-1.0.1 lib/webfinger/response.rb
webfinger-1.0.0 lib/webfinger/response.rb
webfinger-0.0.5 lib/webfinger/response.rb