module Card::Set::Format::AbstractFormat::ViewOpts
handles processing of view definition options (not to be confused with view rendering options. For that, see {Card::View::Options})
Constants
- VIEW_DEF_OPTS
view def opts are used in defining views but are not available at any later point
- VIEW_SETTINGS
view setting values can be accessed from
Format
objects (eg within format blocks in set modules) using view_setting(:setting_name, :view_name)
Private Instance Methods
define_view_setting_method(view, setting_name, setting_value)
click to toggle source
# File lib/card/set/format/abstract_format/view_opts.rb, line 59 def define_view_setting_method view, setting_name, setting_value return unless setting_value method_name = Card::Set::Format.view_setting_method_name view, setting_name define_method(method_name) { setting_value } end
fail_on_invalid_opts!(view, opts)
click to toggle source
# File lib/card/set/format/abstract_format/view_opts.rb, line 32 def fail_on_invalid_opts! view, opts return unless opts.present? raise Card::Error::ServerError, "unknown view opts for #{view} view: #{opts}" end
interpret_view_settings(view, opts)
click to toggle source
# File lib/card/set/format/abstract_format/view_opts.rb, line 49 def interpret_view_settings view, opts return unless opts.present? unknown_ok[view] = true if opts[:unknown] == true VIEW_SETTINGS.each do |setting_name| define_view_setting_method view, setting_name, opts.delete(setting_name) end end
normalize_view_opts(args)
click to toggle source
# File lib/card/set/format/abstract_format/view_opts.rb, line 39 def normalize_view_opts args def_opts = {} def_opts[:alias_to] = args.shift if args[0].is_a?(Symbol) opts = args.shift || {} VIEW_DEF_OPTS.each do |k| def_opts[k] ||= opts.delete k end [def_opts, opts] end
process_view_opts(view, args)
click to toggle source
# File lib/card/set/format/abstract_format/view_opts.rb, line 25 def process_view_opts view, args def_opts, opts = normalize_view_opts args interpret_view_settings view, opts fail_on_invalid_opts! view, opts def_opts end