Sha256: cc80e2f12f53c052ade0ad8548effa678efc84b731ae23b0c7fec87bcaf2aa12

Contents?: true

Size: 1.84 KB

Versions: 18

Compression:

Stored size: 1.84 KB

Contents

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

format :json do

  def get_inclusion_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
    case
    when String === raw    ;  raw
    when 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?       ;  :unknown
# do we want the following to prevent fishing?  of course, they can always post...
    when !card.ok?(:read)   ;  :unknown
    when card.real?         ;  :real
    when card.virtual?      ;  :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/02_basic_types/set/all/json.rb ~~~~~~~~~~~
end;end;end;end;

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
card-1.18.6 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.18.5 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.18.4 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.18.3 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.18.2 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.18.1 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.18.0 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.17.4 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.17.3 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.17.2 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.17.1 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.17.0 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.16.15 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.16.14 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.16.13 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.16.12 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.16.11 tmpsets/set/mod003-02_basic_types/all/json.rb
card-1.16.10 tmpsets/set/mod003-02_basic_types/all/json.rb