Class: Sinclair::Model
- Defined in:
- lib/sinclair/model.rb,
lib/sinclair/model/builder.rb,
lib/sinclair/model/builder_options.rb
Overview
Basic model to be used when defining new classes quickly
Defined Under Namespace
Classes: Builder, BuilderOptions
Class Method Summary collapse
-
.for(*attributes, **options) ⇒ Class<Model>
deprecated
Deprecated.
Use Model.initialize_with instead
-
.initialize_with(*attributes, **options) ⇒ Array<MethodDefinition>
Adds methods needed for the model.
Class Method Details
.for(*attributes, writter: true, comparable: true) ⇒ Class<Model> .for(*attributes, defaults, writter: true, comparable: true) ⇒ Class<Model>
Deprecated.
Use initialize_with instead
Returns a new class that inherits from model
54 55 56 57 58 |
# File 'lib/sinclair/model.rb', line 54 def for(*attributes, **) Class.new(self) do |klass| Builder.new(klass, *attributes, **).build end end |
.initialize_with(*attributes, writter: true, comparable: true) ⇒ Array<MethodDefinition> .initialize_with(*attributes, defaults, writter: true, comparable: true) ⇒ Array<MethodDefinition>
Adds methods needed for the model
The readers/writters, == and initializer are added
103 104 105 |
# File 'lib/sinclair/model.rb', line 103 def initialize_with(*attributes, **) Builder.new(self, *attributes, **).build end |