Module: Card::Set::All::Json::JsonFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod004-format/all/json.rb

Instance Method Summary collapse

Instance Method Details

#default_item_viewObject



18
19
20
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/json.rb', line 18

def default_item_view
  :name
end

#default_nest_viewObject



14
15
16
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/json.rb', line 14

def default_nest_view
  :atom
end

#item_cardsObject

because card.item_cards returns “[[#self]]”



10
11
12
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/json.rb', line 10

def item_cards
  nested_cards
end

#max_depthObject



22
23
24
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/json.rb', line 22

def max_depth
  params[:max_depth].present? ? params[:max_depth].to_i : 1
end

#show(view, args) ⇒ Object

TODO: support layouts in json eg layout=stamp gives you the metadata currently in “page” view and layout=none gives you ONLY the requested view (default atom)



29
30
31
32
33
34
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/json.rb', line 29

def show view, args
  view ||= :molecule
  string_with_page_details do
    render! view, args
  end
end

#view: pageObject



44
45
46
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/json.rb', line 44

view :page, cache: :never do
  page_details card: render_atom
end

#view: statusObject



36
37
38
39
40
41
42
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/json.rb', line 36

view :status, unknown: true, perms: :none do
  { key: card.key,
    url_key: card.name.url_key,
    status: card.state }.tap do |h|
    h[:id] = card.id if h[:status] == :real
  end
end