Class: Zodra::Attribute
- Inherits:
-
Object
- Object
- Zodra::Attribute
- Defined in:
- lib/zodra/attribute.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#enum ⇒ Object
readonly
Returns the value of attribute enum.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#of ⇒ Object
readonly
Returns the value of attribute of.
-
#reference_name ⇒ Object
readonly
Returns the value of attribute reference_name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #array? ⇒ Boolean
- #dependency_name ⇒ Object
-
#initialize(name:, type:, optional: false, nullable: false, format: nil, default: nil, min: nil, max: nil, enum: nil, of: nil, reference_name: nil) ⇒ Attribute
constructor
A new instance of Attribute.
- #nullable? ⇒ Boolean
- #optional? ⇒ Boolean
- #reference? ⇒ Boolean
Constructor Details
#initialize(name:, type:, optional: false, nullable: false, format: nil, default: nil, min: nil, max: nil, enum: nil, of: nil, reference_name: nil) ⇒ Attribute
Returns a new instance of Attribute.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/zodra/attribute.rb', line 7 def initialize(name:, type:, optional: false, nullable: false, format: nil, default: nil, min: nil, max: nil, enum: nil, of: nil, reference_name: nil) @name = name.to_sym @type = type.to_sym @optional = optional @nullable = nullable @format = format @default = default @min = min @max = max @enum = enum @of = of @reference_name = reference_name end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
5 6 7 |
# File 'lib/zodra/attribute.rb', line 5 def default @default end |
#enum ⇒ Object (readonly)
Returns the value of attribute enum.
5 6 7 |
# File 'lib/zodra/attribute.rb', line 5 def enum @enum end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
5 6 7 |
# File 'lib/zodra/attribute.rb', line 5 def format @format end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
5 6 7 |
# File 'lib/zodra/attribute.rb', line 5 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
5 6 7 |
# File 'lib/zodra/attribute.rb', line 5 def min @min end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/zodra/attribute.rb', line 5 def name @name end |
#of ⇒ Object (readonly)
Returns the value of attribute of.
5 6 7 |
# File 'lib/zodra/attribute.rb', line 5 def of @of end |
#reference_name ⇒ Object (readonly)
Returns the value of attribute reference_name.
5 6 7 |
# File 'lib/zodra/attribute.rb', line 5 def reference_name @reference_name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/zodra/attribute.rb', line 5 def type @type end |
Instance Method Details
#array? ⇒ Boolean
34 35 36 |
# File 'lib/zodra/attribute.rb', line 34 def array? type == :array end |
#dependency_name ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/zodra/attribute.rb', line 38 def dependency_name if reference? reference_name.to_sym elsif array? && of of.to_sym end end |
#nullable? ⇒ Boolean
26 27 28 |
# File 'lib/zodra/attribute.rb', line 26 def nullable? @nullable end |
#optional? ⇒ Boolean
22 23 24 |
# File 'lib/zodra/attribute.rb', line 22 def optional? @optional end |
#reference? ⇒ Boolean
30 31 32 |
# File 'lib/zodra/attribute.rb', line 30 def reference? type == :reference end |