Class: ApiNavigator::Attributes

Inherits:
CollectionHash show all
Defined in:
lib/api_navigator/attributes.rb

Overview

A wrapper class to easily acces the attributes in a Resource.

Examples:

resource.attributes['title']
resource.attributes.title

Instance Method Summary collapse

Methods inherited from CollectionHash

#[], #each, #fetch, #include?, #method_missing, #respond_to_missing?, #to_h, #to_s

Constructor Details

#initialize(attributes_hash) ⇒ Attributes

Initializes the Attributes of a Resource.

Parameters:

  • representation

    The hash with the HAL representation of the Resource.

Raises:

  • (ArgumentError)


14
15
16
17
# File 'lib/api_navigator/attributes.rb', line 14

def initialize(attributes_hash)
  raise ArgumentError, "argument nust be a Hash, is #{attributes_hash.class}" unless attributes_hash.kind_of? Hash
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ApiNavigator::CollectionHash