Sha256: 84a84f8b00842ad73e7a154fcce5abf8775d86943ce69812fbe8b7c163e2113f

Contents?: true

Size: 1.47 KB

Versions: 3

Compression:

Stored size: 1.47 KB

Contents

# "Require your project source code, with the correct path"

require "yaks"
require "hamster"

Post = Struct.new(:id, :title, :author, :comments)
Author = Struct.new(:name)

module MyAPI
  Product = Struct.new(:id, :label)

  class ProductMapper < Yaks::Mapper
    attributes :id, :label
  end
end

class AuthorMapper < Yaks::Mapper
end

class CommentMapper < Yaks::Mapper
end

class PostMapper < Yaks::Mapper
  link :self, '/api/posts/{id}'

  attributes :id, :title

  has_one :author
  has_many :comments
end

class HomeMapper < Yaks::Mapper; end

class SpecialMapper < Yaks::Mapper; end

module ActiveSupport
  class TimeWithZone < Time ; end
end

class Currency ; end

module Setup
  def setup
    # Do some nice setup that is run before every snippet
    # If you'd like to use instance variables define them here, e.g
    #  @important_variable_i_will_use_in_my_code_snippets = true
  end

  def teardown
    # Do some cleanup that is run after every snippet
  end

  # If you like local variables you can define methods, e.g
  # def number_of_wishes
  #  101
  # end

  def my_env
    {'something' => true}
  end
  alias_method :rack_env, :my_env

  def post
    Post.new(7, "Yaks is Al Dente", nil, [])
  end
  alias_method :foo, :post

  def product
    MyAPI::Product.new(42, "Shiny thing")
  end

  # # Tell your web framework about the supported formats
  # Yaks::Format.all.each do |format|
  #   mime_type format.format_name, format.media_type
  # end
  def mime_type(*_args)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yaks-0.13.0 ataru_setup.rb
yaks-0.12.0 ataru_setup.rb
yaks-0.11.0 ataru_setup.rb