Module: Card::Set::Format::AbstractFormat
- Defined in:
- lib/card/set/format.rb
Overview
All Format modules are extended with this module in order to support the basic format API (ok, view definitions. It’s just view definitions.)
Instance Method Summary collapse
Instance Method Details
#lookup_alias_block(view, args) ⇒ Object
110 111 112 113 114 115 116 117 118 |
# File 'lib/card/set/format.rb', line 110 def lookup_alias_block view, args opts = args[0].is_a?(Hash) ? args.shift : { view: args.shift } opts[:mod] ||= self opts[:view] ||= view views[opts[:mod]][opts[:view]] || begin raise "cannot find #{opts[:view]} view in #{opts[:mod]}; " \ "failed to alias #{view} in #{self}" end end |
#view(view, *args, &block) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/card/set/format.rb', line 97 def view view, *args, &block view = view.to_viewname.key.to_sym views[self] ||= {} view_block = views[self][view] = if block_given? Card::Format.extract_class_vars view, args[0] block else lookup_alias_block view, args end define_method "_view_#{view}", view_block end |