# File lib/active_graphql/model/configuration.rb, line 71 def primary_key(value = nil) update_or_return_config(:primary_key, value&.to_sym) end
class ActiveGraphql::Model::Configuration
stores all information for how to handle graphql requets for model
Public Class Methods
new()
click to toggle source
# File lib/active_graphql/model/configuration.rb, line 21 def initialize @attributes = [] @primary_key = :id end
Public Instance Methods
attribute(name, nesting = nil, decorate_with: nil)
click to toggle source
# File lib/active_graphql/model/configuration.rb, line 55 def attribute(name, nesting = nil, decorate_with: nil) @attributes << Attribute.new(name, nesting: nesting, decorate_with: decorate_with) end
attributes(*list, **detailed_attributes)
click to toggle source
# File lib/active_graphql/model/configuration.rb, line 45 def attributes(*list, **detailed_attributes) list.each { |name| attribute(name) } detailed_attributes.each { |key, val| attribute(key, val) } @attributes end
attributes_graphql_output()
click to toggle source
# File lib/active_graphql/model/configuration.rb, line 51 def attributes_graphql_output attributes.map(&:to_graphql_output) end
formatter(new_formatter = nil, &block)
click to toggle source
# File lib/active_graphql/model/configuration.rb, line 40 def formatter(new_formatter = nil, &block) @formatter = new_formatter || block if new_formatter || block @formatter ||= Model::ActionFormatter end
graphql_client(client = nil)
click to toggle source
# File lib/active_graphql/model/configuration.rb, line 35 def graphql_client(client = nil) @graphql_client = client if client @graphql_client ||= ActiveGraphql::Client.new(url: url) end
initialize_copy(other)
click to toggle source
Calls superclass method
# File lib/active_graphql/model/configuration.rb, line 26 def initialize_copy(other) super @attributes = other.attributes.dup @graphql_client = other.graphql_client @url = other.url.dup @resource_name = other.resource_name.dup @resource_plural_name = other.resource_plural_name.dup end
primary_key(value = nil)
click to toggle source
resource_name(value = nil)
click to toggle source
# File lib/active_graphql/model/configuration.rb, line 63 def resource_name(value = nil) update_or_return_config(:resource_name, value) end
resource_plural_name(value = nil)
click to toggle source
# File lib/active_graphql/model/configuration.rb, line 67 def resource_plural_name(value = nil) update_or_return_config(:resource_plural_name, value) end
url(value = nil)
click to toggle source
# File lib/active_graphql/model/configuration.rb, line 59 def url(value = nil) update_or_return_config(:url, value) end
Private Instance Methods
update_or_return_config(name, value)
click to toggle source
# File lib/active_graphql/model/configuration.rb, line 77 def update_or_return_config(name, value) instance_variable_set("@#{name}", value) if value instance_variable_get("@#{name}") end