Sha256: 213d2be9fe9ad52860535f5e38b000a5be44c9a73f10e36d5c2bd824d35a825f
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
module Coltrane module UI module Views class View attr_reader :params, :path class << self def inherited(subclass) @questions ||= {} subclass.instance_variable_set(:@questions, @questions.deep_dup) end def questions(question_data) @questions.merge!(question_data) end def set_path(value) @params[:path] = value end def render(**params) remaining_questions = @questions.slice(*(@questions.keys - params.keys)) return { questions: remaining_questions, **params } if remaining_questions.any? view = new(**params) { content: Commands::Render.run(view.render), **params } end end def initialize(**params) @params = params end def output(object) self.class.output(object) end def go_to(path, **params) # App.router.set_next(path, **params) and return end def ensure_param(param_name, &block) @params[param_name] = block.call if @params[param_name].nil? end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
coltrane-4.0.4 | lib/coltrane/ui/views/view.rb |
coltrane-4.0.3 | lib/coltrane/ui/views/view.rb |