Sha256: 6d35217f657c2cb1faea83a66229c59c3800f0fee7a7fb5083449c73f1698100
Contents?: true
Size: 807 Bytes
Versions: 42
Compression:
Stored size: 807 Bytes
Contents
module Graphiti module Util class Class def self.infer_resource_class(parent_resource_class, sideload_name) namespace = namespace_for(parent_resource_class) inferred_name = "#{sideload_name.to_s.singularize.classify}Resource" klass_name = "#{namespace}::#{inferred_name}" tried = [klass_name, inferred_name] klass = klass_name.safe_constantize klass ||= inferred_name.safe_constantize unless klass raise Errors::ResourceNotFound.new(parent_resource_class, sideload_name, tried) end klass end def self.namespace_for(klass) namespace = klass.name return "" unless namespace split = namespace.split("::") split[0, split.length - 1].join("::") end end end end
Version data entries
42 entries across 42 versions & 1 rubygems