Class: Ronan::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ronan/base.rb

Direct Known Subclasses

Downloads, Package, Recipe

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attributes) ⇒ Base

Returns a new instance of Base.



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

def initialize(**attributes)
  self.attributes = attributes
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



18
19
20
21
# File 'lib/ronan/base.rb', line 18

def method_missing(method, *args)
  method = method.to_sym unless method.is_a?(Symbol)
  return attributes[method] || super
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



5
6
7
# File 'lib/ronan/base.rb', line 5

def attributes
  @attributes
end

Class Method Details

.get(path, symbolize: true, **params, &block) ⇒ Object

Raises:



7
8
9
10
11
12
# File 'lib/ronan/base.rb', line 7

def self.get(path, symbolize: true, **params, &block)
  uri = build_uri(path, params)
  res = Net::HTTP.get_response(uri)
  raise HttpError.new(res) unless res.is_a?(Net::HTTPSuccess)
  deserialize(res.body, symbolize: symbolize, &block)
end