module Hatena::Bookmark::Restful::V1::ResponseObject

Public Class Methods

included(context) click to toggle source
# File lib/hatena/bookmark/restful/v1/response_object.rb, line 21
def self.included(context)
  properties = context.const_get(:PROPERTIES)
  context.send(:extend, ClassMethods)
  properties.each do |prop|
    define_method(prop) { @attributes.fetch(prop) }
  end
end
new(attributes) click to toggle source
# File lib/hatena/bookmark/restful/v1/response_object.rb, line 29
def initialize(attributes)
  @attributes = attributes
end

Public Instance Methods

==(other) click to toggle source

@return [Boolean]

# File lib/hatena/bookmark/restful/v1/response_object.rb, line 40
def ==(other)
  other.is_a?(self.class) && self.class.const_get(:PROPERTIES).all? {|prop| self[prop] == other[prop] }
end
[](name) click to toggle source

Fetch raw attribute value @param [Symbol] name The attribute's name

# File lib/hatena/bookmark/restful/v1/response_object.rb, line 35
def [](name)
  @attributes[name]
end
to_hash() click to toggle source

@return [Hash]

# File lib/hatena/bookmark/restful/v1/response_object.rb, line 45
def to_hash
  @attributes
end