Class: Abstract::Builder
- Inherits:
-
Object
- Object
- Abstract::Builder
- Defined in:
- lib/abstracts.rb
Overview
Abstract::Builder class
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Class Method Summary collapse
-
.build {|builder| ... } ⇒ Object
Create an instance of Abstract::Object class and yield block to it.
Instance Method Summary collapse
-
#initialize(object) ⇒ Abstract::Builder
constructor
Define attribute writers to Abstract::Builder instance according to existing accessors of Abstract::Object instance.
Constructor Details
#initialize(object) ⇒ Abstract::Builder
Define attribute writers to Abstract::Builder instance according to
existing accessors of Abstract::Object instance
49 50 51 52 53 54 55 56 |
# File 'lib/abstracts.rb', line 49 def initialize(object) @object = Class.const_get(object).new @object.attrs.each do |attr| define_singleton_method "#{attr}=" do |param| @object.public_send("#{attr}=", param) end end end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
35 36 37 |
# File 'lib/abstracts.rb', line 35 def object @object end |
Class Method Details
.build {|builder| ... } ⇒ Object
Create an instance of Abstract::Object class and yield block to it
39 40 41 42 43 |
# File 'lib/abstracts.rb', line 39 def self.build builder = new(@build_class) yield builder if block_given? builder.object end |