Module: Card::Set::All::Data::DataFormat
- Extended by:
- Card::Set::AbstractFormat
- Defined in:
- platypus/tmp/set/gem-defaults/mod004-format/all/data.rb
Instance Method Summary collapse
-
#atom ⇒ Object
-
#molecule ⇒ Object
-
#nucleus ⇒ Object
NOTE: moving these to methods prevents potential caching problems, because other views manipulate their hashes.
-
#view: ancestors ⇒ Object
-
#view: atom ⇒ Object
TODO: add simple values for fields.
-
#view: cast ⇒ Object
minimum needed to re-fetch card.
-
#view: content ⇒ Object
-
#view: core ⇒ Object
-
#view: items ⇒ Object
NOCACHE because sometimes item_cards is dynamic.
-
#view: links ⇒ Object
-
#view: molecule ⇒ Object
-
#view: nucleus ⇒ Object
-
#view: pod ⇒ Object
Instance Method Details
#atom ⇒ Object
102 103 104 105 106 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/data.rb', line 102 def atom nucleus.tap do |h| h[:content] = render_content if card.known? && !card.structure end end |
#molecule ⇒ Object
108 109 110 111 112 113 114 115 116 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/data.rb', line 108 def molecule atom.merge items: _render_items, links: _render_links, ancestors: _render_ancestors, html_url: path, type: nest(card.type_card, view: :nucleus), created_at: card.created_at, updated_at: card.updated_at end |
#nucleus ⇒ Object
NOTE: moving these to methods prevents potential caching problems, because other views manipulate their hashes.
93 94 95 96 97 98 99 100 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/data.rb', line 93 def nucleus { id: card.id, name: card.name, type: card.type_name, url: path(format: :json) }.tap do |h| h[:codename] = card.codename if card.codename end end |
#view: ancestors ⇒ Object
64 65 66 67 68 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/data.rb', line 64 view :ancestors do card.name.ancestors.map do |name| nest name, view: :nucleus end end |
#view: atom ⇒ Object
TODO: add simple values for fields
56 57 58 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/data.rb', line 56 view :atom, unknown: true do atom end |
#view: cast ⇒ Object
minimum needed to re-fetch card
71 72 73 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/data.rb', line 71 view :cast do card.cast end |
#view: content ⇒ Object
47 48 49 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/data.rb', line 47 view :content do card.content end |
#view: core ⇒ Object
43 44 45 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/data.rb', line 43 view :core, unknown: true do card.known? ? render_content : nil end |
#view: items ⇒ Object
NOCACHE because sometimes item_cards is dynamic. could be safely cached for non-dynamic lists
77 78 79 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/data.rb', line 77 view :items, cache: :never do listing item_cards, view: (voo_items_view || :atom) end |
#view: links ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/data.rb', line 81 view :links do card.link_chunks.map do |chunk| if chunk.referee_name path mark: chunk.referee_name, format: :json else link_to_resource chunk.link_target end end end |
#view: molecule ⇒ Object
60 61 62 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/data.rb', line 60 view :molecule do molecule end |
#view: nucleus ⇒ Object
51 52 53 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/data.rb', line 51 view :nucleus do nucleus end |
#view: pod ⇒ Object
39 40 41 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/data.rb', line 39 view :pod do card.pod_hash end |