Class: Vindi::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/vindi/resource.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Resource

Returns a new instance of Resource.



7
8
9
# File 'lib/vindi/resource.rb', line 7

def initialize(attributes = {})
  @attributes = attributes || {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/vindi/resource.rb', line 15

def method_missing(method_name, *args, &block)
  if attributes.key?(method_name)
    attributes[method_name]
  else
    super
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/vindi/resource.rb', line 5

def attributes
  @attributes
end

Class Method Details

.endpointObject

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/vindi/resource.rb', line 27

def self.endpoint
  raise NotImplementedError, "Subclasses must implement .endpoint"
end

Instance Method Details

#inspectObject



11
12
13
# File 'lib/vindi/resource.rb', line 11

def inspect
  "#<#{self.class} #{attributes.inspect}>"
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/vindi/resource.rb', line 23

def respond_to_missing?(method_name, include_private = false)
  attributes.key?(method_name) || super
end