Sha256: e790e8df8955c9681f08980d74f5fd1bfcd5ed9d3262b6ac4d1b3ef68cc30828

Contents?: true

Size: 1.81 KB

Versions: 49

Compression:

Stored size: 1.81 KB

Contents

# -*- encoding : utf-8 -*-
class Card; module Set; class All; module Json; extend Card::Set
# ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/basic_formats/set/all/json.rb ~~

format :json do
  def get_nest_defaults _nested_card
    { view: :atom }
  end

  def default_item_view
    params[:item] || :atom
  end

  def max_depth
    params[:max_depth] || 1
  end

  def show view, args
    view ||= :content
    raw = render view, args
    if raw.is_a?(String)
      raw
    elsif params[:compress]
      JSON(raw)
    else
      JSON.pretty_generate raw
    end
  end

  view :name_complete do |_args|
    card.item_cards complete: params["term"], limit: 8, sort: "name",
                    return: "name", context: ""
  end

  view :status, tags: :unknown_ok, perms: :none do |_args|
    status =
      case
      when !card.known?     then :unknown
      # do we want the following to prevent fishing?  of course, they can always
      # post...
      when !card.ok?(:read) then :unknown
      when card.real?       then :real
      when card.virtual?    then :virtual
      else :wtf
      end

    hash = { key: card.key, url_key: card.cardname.url_key, status: status }
    hash[:id] = card.id if status == :real

    hash
  end

  view :content do |_args|
    req = controller.request
    {
      url:       (req && req.original_url),
      timestamp: Time.now.to_s,
      card:      _render_atom
    }
  end

  view :atom do |args|
    h = {
      name: card.name,
      type: card.type_name
    }
    h[:content]  = card.content  unless card.structure
    h[:codename] = card.codename     if card.codename
    h[:value]    = _render_core args if @depth < max_depth
    h
  end
end


# ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/basic_formats/set/all/json.rb ~~
end;end;end;end;

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
card-1.99.6 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.99.5 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.97.0.1 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.97.0 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.96.8 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.96.7 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.96.6 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.96.5 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.96.4 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.96.3 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.96.2 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.96.1 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.96.0 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.95.3 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.95.2 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.95.1 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.95.0 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.94.1 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.94.0 tmpsets/set/mod004-basic_formats/all/json.rb
card-1.93.13 tmpsets/set/mod004-basic_formats/all/json.rb