class DearInventory::EndpointClass
Public Class Methods
call(class_type:, resource_class:, endpoint:)
click to toggle source
# File lib/dear_inventory/lib/endpoint_class.rb, line 17 def self.call(class_type:, resource_class:, endpoint:) new( class_type: class_type, resource_class: resource_class, endpoint: endpoint ).call end
new(class_type:, resource_class:, endpoint:)
click to toggle source
# File lib/dear_inventory/lib/endpoint_class.rb, line 32 def initialize(class_type:, resource_class:, endpoint:) @class_type = T.let(class_type, String) @resource_class = T.let(resource_class, T.untyped) @endpoint = T.let(endpoint || "Index", String) @class_name = T.let(nil, T.nilable(String)) end
Public Instance Methods
call()
click to toggle source
# File lib/dear_inventory/lib/endpoint_class.rb, line 40 def call Object.const_get(class_name) if Object.const_defined?(class_name) end
Private Instance Methods
class_name()
click to toggle source
# File lib/dear_inventory/lib/endpoint_class.rb, line 47 def class_name @class_name ||= begin name = ["DearInventory"] name << @class_type name << @resource_class.name.split("::").last name << @endpoint.split("_").map(&:capitalize).join name.join("::") end end