Module: PartyResource

Defined in:
lib/party_resource/route.rb,
lib/party_resource/request.rb,
lib/party_resource/property.rb,
lib/party_resource/buildable.rb,
lib/party_resource/connector.rb,
lib/party_resource/exceptions.rb,
lib/party_resource/connector/base.rb,
lib/party_resource/party_resource.rb

Defined Under Namespace

Modules: Buildable, ClassMethods, Connector, Exceptions, ParameterValues Classes: Property, Request, Route

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.loggerObject



19
20
21
# File 'lib/party_resource/party_resource.rb', line 19

def self.logger
  @logger
end

.logger=(logger) ⇒ Object

Set logger to use

Parameters:

  • logger

    One of:

    nil - no logging

    Proc - log using logger.call(message)

    Object - log using logger.debug(message)



14
15
16
# File 'lib/party_resource/party_resource.rb', line 14

def self.logger=(logger)
  @logger = logger
end

Instance Method Details

#properties_equal?(other) ⇒ Boolean

Test if all properties are equal

Returns:

  • (Boolean)


167
168
169
170
171
172
173
# File 'lib/party_resource/party_resource.rb', line 167

def properties_equal?(other)
  begin
    self.class.send(:property_list).all? {|property| self.send(property.name) == other.send(property.name) }
  rescue NoMethodError
    false
  end
end

#to_properties_hashHash

Converts the objects properties to a hash

Returns:

  • (Hash)

    a hash of all the properties



160
161
162
163
164
# File 'lib/party_resource/party_resource.rb', line 160

def to_properties_hash
  self.class.send(:property_list).inject({}) do |hash, property|
    hash.merge(property.to_hash(self))
  end
end