Class: Vorpal::Dsl::ConfigBuilder
- Inherits:
-
Object
- Object
- Vorpal::Dsl::ConfigBuilder
- Defined in:
- lib/vorpal/dsl/config_builder.rb
Instance Method Summary collapse
- #attributes(*attributes) ⇒ Object
- #attributes_with_id ⇒ Object
- #belongs_to(name, options = {}) ⇒ Object
- #build ⇒ Object
- #has_many(name, options = {}) ⇒ Object
- #has_one(name, options = {}) ⇒ Object
-
#initialize(clazz, options, db_driver) ⇒ ConfigBuilder
constructor
A new instance of ConfigBuilder.
Constructor Details
#initialize(clazz, options, db_driver) ⇒ ConfigBuilder
Returns a new instance of ConfigBuilder.
12 13 14 15 16 17 18 19 20 |
# File 'lib/vorpal/dsl/config_builder.rb', line 12 def initialize(clazz, , db_driver) @domain_class = clazz @class_options = @has_manys = [] @has_ones = [] @belongs_tos = [] @attributes = [] @defaults_generator = DefaultsGenerator.new(clazz, db_driver) end |
Instance Method Details
#attributes(*attributes) ⇒ Object
23 24 25 |
# File 'lib/vorpal/dsl/config_builder.rb', line 23 def attributes(*attributes) @attributes.concat(attributes) end |
#attributes_with_id ⇒ Object
53 54 55 |
# File 'lib/vorpal/dsl/config_builder.rb', line 53 def attributes_with_id [:id].concat @attributes end |
#belongs_to(name, options = {}) ⇒ Object
38 39 40 |
# File 'lib/vorpal/dsl/config_builder.rb', line 38 def belongs_to(name, ={}) @belongs_tos << build_belongs_to({name: name}.merge()) end |
#build ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/vorpal/dsl/config_builder.rb', line 43 def build class_config = build_class_config class_config.has_manys = @has_manys class_config.has_ones = @has_ones class_config.belongs_tos = @belongs_tos class_config end |
#has_many(name, options = {}) ⇒ Object
28 29 30 |
# File 'lib/vorpal/dsl/config_builder.rb', line 28 def has_many(name, ={}) @has_manys << build_has_many({name: name}.merge()) end |
#has_one(name, options = {}) ⇒ Object
33 34 35 |
# File 'lib/vorpal/dsl/config_builder.rb', line 33 def has_one(name, ={}) @has_ones << build_has_one({name: name}.merge()) end |