Class: Redd::Objects::Base

Inherits:
Hashie::Hash
  • Object
show all
Extended by:
Forwardable
Includes:
Hashie::Extensions::DeepMerge, Hashie::Extensions::MergeInitializer, Hashie::Extensions::MethodQuery, Hashie::Extensions::MethodReader
Defined in:
lib/redd/objects/base.rb

Overview

A base for all objects to inherit from.

Direct Known Subclasses

LabeledMulti, Thing

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, attributes = {}) ⇒ Base

Returns a new instance of Base.

Parameters:

  • client (Clients::Base)

    The client instance.

  • attributes (Hash) (defaults to: {})

    A hash of attributes.



25
26
27
28
# File 'lib/redd/objects/base.rb', line 25

def initialize(client, attributes = {})
  @client = client
  super(attributes)
end

Instance Attribute Details

#clientClients::Base (readonly)

Returns The client that used to make requests.

Returns:



21
22
23
# File 'lib/redd/objects/base.rb', line 21

def client
  @client
end

Class Method Details

.alias_property(new_name, old_name) ⇒ Object

Define an alias for a property.

Parameters:

  • new_name (Symbol)

    The alias.

  • old_name (Symbol)

    The existing property.



33
34
35
36
# File 'lib/redd/objects/base.rb', line 33

def self.alias_property(new_name, old_name)
  define_method(new_name) { send(old_name) }
  define_method(:"#{new_name}?") { send(old_name) }
end