rx/presenters

View on GitHub
app/demo/shared/context_list.pom

Summary

Maintainability
Test Coverage
Voom::Presenters.define(:context_list) do
  helpers do
    def title
      context.fetch(:title) {'Context'}
    end

    def time
      Time.now unless context.fetch(:hide_time) {true}
    end

    def scrubbed_context
      scrubbed_keys = context.fetch(:exclude) {%w{title file hide_time _presenter_ _namespace1_ session}}
      context.select {|k, _| !scrubbed_keys.include?(k.to_s)}
    end
  end
  content id: :context_list do
    grid do
      column 12 do
        headline title
        subheading "#{time}"
        list do
          scrubbed_context.map {|k, v| "#{k}: #{v}"}.each do |param|
            line param
          end
        end
      end
    end
  end
end