Sha256: ae0d4fafdc6c38ab6305ed769b8f5ed30838eb2eff86bc22345a31aab0015280
Contents?: true
Size: 988 Bytes
Versions: 40
Compression:
Stored size: 988 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 def self.graphql_type_name(name) name.gsub("Resource", "") .gsub("::", "") # remove modules .gsub(".", "__") # remove remote resource . end end end end
Version data entries
40 entries across 40 versions & 1 rubygems