Class: Slotify::ValueCollection
- Inherits:
-
Object
- Object
- Slotify::ValueCollection
- Includes:
- Enumerable
- Defined in:
- lib/slotify/value_collection.rb
Instance Method Summary collapse
-
#initialize(values = []) ⇒ ValueCollection
constructor
A new instance of ValueCollection.
- #render_in(view_context, &block) ⇒ Object
- #to_s ⇒ Object
- #with_default_options ⇒ Object
- #with_partial_path ⇒ Object
Constructor Details
#initialize(values = []) ⇒ ValueCollection
Returns a new instance of ValueCollection.
7 8 9 |
# File 'lib/slotify/value_collection.rb', line 7 def initialize(values = []) @values = values.is_a?(Value) ? [values] : values end |
Instance Method Details
#render_in(view_context, &block) ⇒ Object
25 26 27 28 29 |
# File 'lib/slotify/value_collection.rb', line 25 def render_in(view_context, &block) @values.reduce(ActiveSupport::SafeBuffer.new) do |buffer, value| buffer << value.render_in(view_context, &block) end end |
#to_s ⇒ Object
19 20 21 22 23 |
# File 'lib/slotify/value_collection.rb', line 19 def to_s @values.reduce(ActiveSupport::SafeBuffer.new) do |buffer, value| buffer << value.to_s end end |
#with_default_options ⇒ Object
11 12 13 |
# File 'lib/slotify/value_collection.rb', line 11 def (...) ValueCollection.new(map { _1.(...) }) end |
#with_partial_path ⇒ Object
15 16 17 |
# File 'lib/slotify/value_collection.rb', line 15 def with_partial_path(...) ValueCollection.new(map { _1.with_partial_path(...) }) end |