Method: Pakyow::Presenter::View#transform
- Defined in:
- lib/pakyow/presenter/view.rb
#transform(object) ⇒ Object
Transforms self
to match structure of object
.
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/pakyow/presenter/view.rb', line 249 def transform(object) tap do if object.nil? || (object.respond_to?(:empty?) && object.empty?) remove else removals = [] each_binding_prop(descend: false) do |binding| binding_name = if binding.significant?(:multipart_binding) binding.label(:binding_prop) else binding.label(:binding) end unless object.present?(binding_name) removals << binding end end removals.each(&:remove) end yield self, object if block_given? end end |