class FilmwebApi
Attributes
attributes[R]
method[R]
Public Class Methods
new(method:, **attributes)
click to toggle source
# File lib/filmweb_api.rb, line 8 def initialize(method:, **attributes) @method = method @attributes = attributes end
Public Instance Methods
get()
click to toggle source
# 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
Private Instance Methods
correct_attributes_for_method?()
click to toggle source
# File lib/filmweb_api.rb, line 25 def correct_attributes_for_method? method_handler::REQUEST_ATTRIBUTES.all? { |sym| attributes.key?(sym) } end
method_defined?()
click to toggle source
# File lib/filmweb_api.rb, line 21 def method_defined? defined?(method_handler) == "method" end
method_handler()
click to toggle source
# File lib/filmweb_api.rb, line 29 def method_handler "#{method.slice(0,1).capitalize + method.slice(1..-1)}Handler".constantize end