Class: Artisanal::Model::Builder

Inherits:
Module
  • Object
show all
Defined in:
lib/artisanal/model/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Builder

Returns a new instance of Builder.

[View source]

9
10
11
# File 'lib/artisanal/model/builder.rb', line 9

def initialize(options={})
  @config = Config.new(options)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.


7
8
9
# File 'lib/artisanal/model/builder.rb', line 7

def config
  @config
end

Instance Method Details

#included(base) ⇒ Object

[View source]

13
14
15
16
17
18
19
20
21
22
# File 'lib/artisanal/model/builder.rb', line 13

def included(base)
  base.extend Dry::Initializer[undefined: config.undefined?]
  base.extend Artisanal::Model::DSL

  # Make attributes mutable
  define_writers if config.writable?

  # Store artisanal model config
  base.artisanal_model.config = config
end