Sha256: f18b5738975213e39e3154981099fab745c1e07188ea9692b33ca6b2fbd6cfec
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true require 'graphql_rails/attribute' require 'graphql_rails/model/graphql_type_builder' module GraphqlRails module Model # stores information about model specific config, like attributes and types class Configuration attr_reader :attributes def initialize(model_class) @model_class = model_class @attributes = {} end def name(type_name = nil) @name = type_name if type_name @name || name_by_class_name end def description(new_description = nil) @description = new_description if new_description @description end def attribute(attribute_name, type: nil, **attribute_options) attributes[attribute_name.to_s] = \ Attribute.new( attribute_name, type, attribute_options ) end def graphql_type @graphql_type ||= GrapqhlTypeBuilder.new( name: name, description: description, attributes: attributes ).call end private attr_reader :model_class def name_by_class_name @name_by_class_name ||= model_class.name.split('::').last end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
graphql_rails-0.3.1 | lib/graphql_rails/model/configuration.rb |
graphql_rails-0.3.0 | lib/graphql_rails/model/configuration.rb |
graphql_rails-0.2.4 | lib/graphql_rails/model/configuration.rb |