Module: GraphqlRails::Attributes::AttributeConfigurable

Extended by:
ActiveSupport::Concern
Included in:
Attribute, InputAttribute
Defined in:
lib/graphql_rails/attributes/attribute_configurable.rb

Overview

Allows to set or get various attribute parameters

Instance Method Summary collapse

Instance Method Details

#deprecated(reason = 'Deprecated') ⇒ Object



53
54
55
56
57
58
59
60
61
62
# File 'lib/graphql_rails/attributes/attribute_configurable.rb', line 53

def deprecated(reason = 'Deprecated')
  @deprecation_reason = \
    if [false, nil].include?(reason)
      nil
    else
      reason.is_a?(String) ? reason : 'Deprecated'
    end

  self
end

#deprecation_reasonObject



64
65
66
# File 'lib/graphql_rails/attributes/attribute_configurable.rb', line 64

def deprecation_reason
  @deprecation_reason
end

#group(*args) ⇒ Object



32
33
34
# File 'lib/graphql_rails/attributes/attribute_configurable.rb', line 32

def group(*args)
  groups(*args)
end

#groups(new_groups = ChainableOptions::NOT_SET) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/graphql_rails/attributes/attribute_configurable.rb', line 24

def groups(new_groups = ChainableOptions::NOT_SET)
  @groups ||= []
  return @groups if new_groups == ChainableOptions::NOT_SET

  @groups = Array(new_groups).map(&:to_s)
  self
end

#hidden_in_groups(new_groups = ChainableOptions::NOT_SET) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/graphql_rails/attributes/attribute_configurable.rb', line 36

def hidden_in_groups(new_groups = ChainableOptions::NOT_SET)
  @hidden_in_groups ||= []
  return @hidden_in_groups if new_groups == ChainableOptions::NOT_SET

  @hidden_in_groups = Array(new_groups).map(&:to_s)
  self
end

#optional(new_value = true) ⇒ Object

rubocop:disable Style/OptionalBooleanParameter



49
50
51
# File 'lib/graphql_rails/attributes/attribute_configurable.rb', line 49

def optional(new_value = true) # rubocop:disable Style/OptionalBooleanParameter
  required(!new_value)
end

#property(new_value = ChainableOptions::NOT_SET) ⇒ Object



68
69
70
71
72
73
# File 'lib/graphql_rails/attributes/attribute_configurable.rb', line 68

def property(new_value = ChainableOptions::NOT_SET)
  return @property if new_value == ChainableOptions::NOT_SET

  @property = new_value.to_s
  self
end

#required(new_value = true) ⇒ Object

rubocop:disable Style/OptionalBooleanParameter



44
45
46
47
# File 'lib/graphql_rails/attributes/attribute_configurable.rb', line 44

def required(new_value = true) # rubocop:disable Style/OptionalBooleanParameter
  @required = new_value
  self
end

#same_as(other_attribute) ⇒ Object



75
76
77
78
79
80
81
82
83
84
# File 'lib/graphql_rails/attributes/attribute_configurable.rb', line 75

def same_as(other_attribute)
  other = other_attribute.dup
  other.instance_variables.each do |instance_variable|
    next if instance_variable == :@initial_name

    instance_variable_set(instance_variable, other.instance_variable_get(instance_variable))
  end

  self
end