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| ... } ⇒ AbstractObject
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
57 58 59 60 61 62 63 64 |
# File 'lib/abstracts.rb', line 57 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.
43 44 45 |
# File 'lib/abstracts.rb', line 43 def object @object end |
Class Method Details
.build {|builder| ... } ⇒ AbstractObject
Create an instance of Abstract::Object class and yield block to it
47 48 49 50 51 |
# File 'lib/abstracts.rb', line 47 def self.build builder = new(@build_class) yield builder if block_given? builder.object end |