Class: QueryBuilder::Core::Attribute
- Inherits:
-
Object
- Object
- QueryBuilder::Core::Attribute
- Defined in:
- lib/query_builder/core/attribute.rb
Overview
Describes the attribute of AST node
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
The default value for the attribute.
-
#name ⇒ Symbol
readonly
The name of the attribute.
-
#required ⇒ Boolean
readonly
Whether the attribute is required or not.
Instance Method Summary collapse
-
#arguments ⇒ Array
Returns arguments of the attribute initializer.
-
#initialize(name, options = {}) ⇒ Attribute
constructor
Initializes the attribute with name and options.
Constructor Details
#initialize(name, options = {}) ⇒ Attribute
Initializes the attribute with name and options
36 37 38 39 40 41 42 |
# File 'lib/query_builder/core/attribute.rb', line 36 def initialize(name, = {}) @name = name @default = [:default] @required = .fetch(:required) { false } IceNine.deep_freeze(self) end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns The default value for the attribute.
21 22 23 |
# File 'lib/query_builder/core/attribute.rb', line 21 def default @default end |
#name ⇒ Symbol (readonly)
Returns The name of the attribute.
15 16 17 |
# File 'lib/query_builder/core/attribute.rb', line 15 def name @name end |
#required ⇒ Boolean (readonly)
Returns Whether the attribute is required or not.
27 28 29 |
# File 'lib/query_builder/core/attribute.rb', line 27 def required @required end |
Instance Method Details
#arguments ⇒ Array
Returns arguments of the attribute initializer
48 49 50 |
# File 'lib/query_builder/core/attribute.rb', line 48 def arguments [name, default: default, required: required] end |