Class: CompEx::Bag
- Inherits:
-
Object
- Object
- CompEx::Bag
- Defined in:
- lib/compex/bag.rb
Instance Method Summary collapse
-
#initialize(parent, **args) ⇒ Bag
constructor
A new instance of Bag.
- #render(klass, **args) ⇒ Object
- #required_hashes ⇒ Object
Constructor Details
#initialize(parent, **args) ⇒ Bag
Returns a new instance of Bag.
5 6 7 8 9 10 11 12 13 |
# File 'lib/compex/bag.rb', line 5 def initialize(parent, **args) parent.args.each do |arg| next unless args.key? arg define_singleton_method(arg) { args[arg] } end @_extra_css_hashes = [] @_extra_js_hashes = [] end |
Instance Method Details
#render(klass, **args) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/compex/bag.rb', line 19 def render(klass, **args) inst = klass.new(**args) @_extra_css_hashes << inst.css_hash @_extra_js_hashes << inst.js_hash inst.render_html end |
#required_hashes ⇒ Object
15 16 17 |
# File 'lib/compex/bag.rb', line 15 def required_hashes [@_extra_css_hashes, @_extra_js_hashes].compact.flatten end |