Class: QueryBuilder::Core::Base Abstract
- Inherits:
-
Object
- Object
- QueryBuilder::Core::Base
- Defined in:
- lib/query_builder/core/base.rb
Overview
This class is abstract.
The abstract base class for all nodes of AST: statemens, clauses, operators
Declares common attributes, ‘#initializer`, and `#to_s` instance methods.
Instance Attribute Summary collapse
-
#attributes ⇒ Hash
readonly
The hash of the initialized attributes.
Class Method Summary collapse
-
.attribute(name, options = {}) ⇒ undefined
Declares the attribute with optional default value.
-
.attributes ⇒ Hash
The hash of default attributes of class’ instances.
-
.inherited(subclass) ⇒ Object
Makes default attributes inheritable.
Instance Method Summary collapse
-
#attribute(name, options) ⇒ undefined
Declares the attribute with optional default value.
-
#initialize(attributes = {}) ⇒ Base
constructor
Initializes the instance.
-
#to_s ⇒ String
abstract
Returns the current chunk of CQL statement.
Constructor Details
#initialize(attributes = {}) ⇒ Base
Initializes the instance
57 58 59 60 61 62 63 |
# File 'lib/query_builder/core/base.rb', line 57 def initialize(attributes = {}) validate_unknown attributes validate_missing attributes @attributes = default_attributes.merge(attributes) IceNine.deep_freeze(self) end |
Instance Attribute Details
#attributes ⇒ Hash (readonly)
Returns The hash of the initialized attributes.
18 19 20 |
# File 'lib/query_builder/core/base.rb', line 18 def self.attributes @attributes ||= Set.new end |
Class Method Details
.attribute(name, options = {}) ⇒ undefined
Declares the attribute with optional default value
31 32 33 34 |
# File 'lib/query_builder/core/base.rb', line 31 def self.attribute(name, = {}) attributes << Attribute.new(name, ) define_method(name) { attributes.fetch(name) } end |
.attributes ⇒ Hash
The hash of default attributes of class’ instances
18 19 20 |
# File 'lib/query_builder/core/base.rb', line 18 def self.attributes @attributes ||= Set.new end |
.inherited(subclass) ⇒ Object
Makes default attributes inheritable
40 41 42 43 44 |
# File 'lib/query_builder/core/base.rb', line 40 def self.inherited(subclass) attributes.each do |item| subclass.public_send(:attribute, *item.arguments) end end |
Instance Method Details
#attribute(name, options) ⇒ undefined
Declares the attribute with optional default value
31 32 33 34 |
# File 'lib/query_builder/core/base.rb', line 31 def self.attribute(name, = {}) attributes << Attribute.new(name, ) define_method(name) { attributes.fetch(name) } end |
#to_s ⇒ String
This method is abstract.
Returns the current chunk of CQL statement
72 73 74 |
# File 'lib/query_builder/core/base.rb', line 72 def to_s "" end |