Class: ShipMe::Template
- Inherits:
-
Object
- Object
- ShipMe::Template
- Defined in:
- lib/ship_me/template.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#options_block ⇒ Object
Returns the value of attribute options_block.
Instance Method Summary collapse
-
#initialize(klass) ⇒ Template
constructor
A new instance of Template.
- #make(attributes = {}) ⇒ Object
Constructor Details
#initialize(klass) ⇒ Template
Returns a new instance of Template.
6 7 8 |
# File 'lib/ship_me/template.rb', line 6 def initialize(klass) @klass = klass end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
3 4 5 |
# File 'lib/ship_me/template.rb', line 3 def klass @klass end |
#options_block ⇒ Object
Returns the value of attribute options_block.
4 5 6 |
# File 'lib/ship_me/template.rb', line 4 def @options_block end |
Instance Method Details
#make(attributes = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ship_me/template.rb', line 10 def make(attributes = {}) proxy = Module.new attributes.each do |method, value| (class << proxy; self; end).send(:define_method, method) do value end end opts = proxy.instance_eval(&) @klass.new(opts) end |