class Card::Format
Card::Format
and its subclasses ({Card::Format::HtmlFormat}, {Card::Format::JsonFormat}, {Card::Format::XmlFormat}, etc) are responsible for defining and rendering views.
However, monkeys (those who code in the Card/Decko framework) rarely write code directly in these classes. Instead they organize their code using {Cardio::Mod mods}.
{Cardio::Mod} explains how to set up a mod. {Card::Set::Format} explains how to use this and other format classes within a mod. {Card::Set::Format::AbstractFormat} introduces the view API, which is organized with these format classes.
Attributes
symbol[W]
card[R]
error_status[RW]
form[RW]
main_opts[R]
modal_opts[R]
parent[R]
rendered[RW]
Public Class Methods
new(card, opts={})
click to toggle source
# File lib/card/format.rb, line 48 def initialize card, opts={} @card = card require_card_to_initialize! opts.each { |key, value| instance_variable_set "@#{key}", value } include_set_format_modules end
view_caching?()
click to toggle source
# File lib/card/format.rb, line 43 def view_caching? true end
Public Instance Methods
controller()
click to toggle source
# File lib/card/format.rb, line 77 def controller @controller || Env.controller ||= CardController.new end
escape_literal(literal)
click to toggle source
# File lib/card/format.rb, line 89 def escape_literal literal literal end
include_set_format_modules()
click to toggle source
# File lib/card/format.rb, line 61 def include_set_format_modules self.class.format_ancestry.reverse_each do |klass| card.set_format_modules(klass).each do |m| singleton_class.send :include, m end end end
mime_type()
click to toggle source
# File lib/card/format.rb, line 85 def mime_type "text/plain" end
page(controller, view, slot_opts)
click to toggle source
# File lib/card/format.rb, line 69 def page controller, view, slot_opts @controller = controller context_names # loads names and removes #name_context from slot_opts @card.run_callbacks :show_page do show view, slot_opts end end
request_url()
click to toggle source
# File lib/card/format.rb, line 81 def request_url controller.request&.original_url || path end
require_card_to_initialize!()
click to toggle source
# File lib/card/format.rb, line 55 def require_card_to_initialize! return if @card raise Card::Error, ::I18n.t(:lib_exception_init_without_card) end
symbol()
click to toggle source
# File lib/card/format.rb, line 93 def symbol self.class.symbol end
Also aliased as: to_sym