Class: AssociateJsonb::ConnectionAdapters::ConstraintDefinition
- Inherits:
-
Object
- Object
- AssociateJsonb::ConnectionAdapters::ConstraintDefinition
- Defined in:
- lib/associate_jsonb/connection_adapters/schema_definitions/constraint_definition.rb
Instance Attribute Summary collapse
-
#deferrable ⇒ Object
readonly
rubocop:disable Metrics/ParameterLists.
-
#force ⇒ Object
readonly
rubocop:disable Metrics/ParameterLists.
-
#name ⇒ Object
readonly
rubocop:disable Metrics/ParameterLists.
-
#not_valid ⇒ Object
readonly
rubocop:disable Metrics/ParameterLists.
-
#value ⇒ Object
readonly
rubocop:disable Metrics/ParameterLists.
Instance Method Summary collapse
- #deferrable? ⇒ Boolean
- #deferrable_default? ⇒ Boolean
- #force? ⇒ Boolean
-
#initialize(value:, name: nil, not_valid: false, force: false, deferrable: true) ⇒ ConstraintDefinition
constructor
A new instance of ConstraintDefinition.
- #name? ⇒ Boolean
- #not_valid? ⇒ Boolean
- #to_h ⇒ Object (also: #to_hash)
- #value? ⇒ Boolean
Constructor Details
#initialize(value:, name: nil, not_valid: false, force: false, deferrable: true) ⇒ ConstraintDefinition
Returns a new instance of ConstraintDefinition.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/constraint_definition.rb', line 9 def initialize(value:, name: nil, not_valid: false, force: false, deferrable: true, **) @name = name.presence @value = value @not_valid = not_valid @deferrable = deferrable @force = force @name ||= "rails_constraint_" \ "#{@value.hash}" \ "_#{not_valid ? "nv" : "v"}" \ "_#{deferrable ? "d" : "nd"}" end |
Instance Attribute Details
#deferrable ⇒ Object (readonly)
rubocop:disable Metrics/ParameterLists
8 9 10 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/constraint_definition.rb', line 8 def deferrable @deferrable end |
#force ⇒ Object (readonly)
rubocop:disable Metrics/ParameterLists
8 9 10 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/constraint_definition.rb', line 8 def force @force end |
#name ⇒ Object (readonly)
rubocop:disable Metrics/ParameterLists
8 9 10 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/constraint_definition.rb', line 8 def name @name end |
#not_valid ⇒ Object (readonly)
rubocop:disable Metrics/ParameterLists
8 9 10 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/constraint_definition.rb', line 8 def not_valid @not_valid end |
#value ⇒ Object (readonly)
rubocop:disable Metrics/ParameterLists
8 9 10 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/constraint_definition.rb', line 8 def value @value end |
Instance Method Details
#deferrable? ⇒ Boolean
40 41 42 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/constraint_definition.rb', line 40 def deferrable? !!deferrable end |
#deferrable_default? ⇒ Boolean
23 24 25 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/constraint_definition.rb', line 23 def deferrable_default? deferrable.nil? end |
#force? ⇒ Boolean
44 45 46 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/constraint_definition.rb', line 44 def force? !!force end |
#name? ⇒ Boolean
28 29 30 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/constraint_definition.rb', line 28 def name? !!name end |
#not_valid? ⇒ Boolean
36 37 38 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/constraint_definition.rb', line 36 def not_valid? !!not_valid end |
#to_h ⇒ Object Also known as: to_hash
48 49 50 51 52 53 54 55 56 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/constraint_definition.rb', line 48 def to_h { name: name, value: value, not_valid: not_valid, deferrable: deferrable, force: force } end |
#value? ⇒ Boolean
32 33 34 |
# File 'lib/associate_jsonb/connection_adapters/schema_definitions/constraint_definition.rb', line 32 def value? !!value end |