Class: FilmwebApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method:, **attributes) ⇒ FilmwebApi

Returns a new instance of FilmwebApi.



8
9
10
11
# File 'lib/filmweb_api.rb', line 8

def initialize(method:, **attributes)
  @method = method
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



6
7
8
# File 'lib/filmweb_api.rb', line 6

def attributes
  @attributes
end

#methodObject (readonly)

Returns the value of attribute method.



6
7
8
# File 'lib/filmweb_api.rb', line 6

def method
  @method
end

Instance Method Details

#getObject

Raises:

  • (ArgumentError)


13
14
15
16
17
# File 'lib/filmweb_api.rb', line 13

def get
  raise ArgumentError.new("Passed method not supported") unless method_defined?
  raise ArgumentError.new("You need to pass all required attributes for that method") unless correct_attributes_for_method?
  method_handler.new(attributes.slice(*method_handler::REQUEST_ATTRIBUTES)).call
end