yaks-html 0.6.0.alpha → 0.6.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -525
- data/Rakefile +1 -41
- data/{yaks-html/lib → lib}/yaks-html.rb +0 -0
- data/{yaks-html/lib → lib}/yaks/format/html.rb +0 -0
- data/{yaks-html/lib → lib}/yaks/format/template.html +0 -0
- data/{yaks-html/spec → spec}/spec_helper.rb +0 -0
- data/{yaks-html/yaks-html.gemspec → yaks-html.gemspec} +1 -1
- metadata +11 -108
- data/.gitignore +0 -7
- data/.travis.yml +0 -36
- data/ADDING_FORMATS.md +0 -13
- data/CHANGELOG.md +0 -149
- data/Gemfile +0 -4
- data/IDENTIFIERS.md +0 -113
- data/LICENSE +0 -7
- data/bench/bench.rb +0 -16
- data/bench/bench_1000.rb +0 -60
- data/notes.org +0 -72
- data/shaved_yak.gif +0 -0
- data/yaks-html/README.md +0 -3
- data/yaks/README.md +0 -526
- data/yaks/lib/yaks.rb +0 -62
- data/yaks/lib/yaks/breaking_changes.rb +0 -49
- data/yaks/lib/yaks/collection_mapper.rb +0 -52
- data/yaks/lib/yaks/collection_resource.rb +0 -73
- data/yaks/lib/yaks/config.rb +0 -65
- data/yaks/lib/yaks/config/dsl.rb +0 -165
- data/yaks/lib/yaks/default_policy.rb +0 -100
- data/yaks/lib/yaks/format.rb +0 -87
- data/yaks/lib/yaks/format/collection_json.rb +0 -42
- data/yaks/lib/yaks/format/hal.rb +0 -82
- data/yaks/lib/yaks/format/json_api.rb +0 -86
- data/yaks/lib/yaks/fp.rb +0 -26
- data/yaks/lib/yaks/fp/callable.rb +0 -9
- data/yaks/lib/yaks/fp/hash_updatable.rb +0 -19
- data/yaks/lib/yaks/fp/updatable.rb +0 -17
- data/yaks/lib/yaks/mapper.rb +0 -75
- data/yaks/lib/yaks/mapper/association.rb +0 -43
- data/yaks/lib/yaks/mapper/association_mapper.rb +0 -42
- data/yaks/lib/yaks/mapper/attribute.rb +0 -17
- data/yaks/lib/yaks/mapper/class_methods.rb +0 -37
- data/yaks/lib/yaks/mapper/config.rb +0 -44
- data/yaks/lib/yaks/mapper/has_many.rb +0 -29
- data/yaks/lib/yaks/mapper/has_one.rb +0 -15
- data/yaks/lib/yaks/mapper/link.rb +0 -91
- data/yaks/lib/yaks/null_resource.rb +0 -40
- data/yaks/lib/yaks/primitivize.rb +0 -45
- data/yaks/lib/yaks/resource.rb +0 -51
- data/yaks/lib/yaks/resource/link.rb +0 -21
- data/yaks/lib/yaks/runner.rb +0 -101
- data/yaks/lib/yaks/util.rb +0 -56
- data/yaks/lib/yaks/version.rb +0 -3
- data/yaks/spec/acceptance/acceptance_spec.rb +0 -48
- data/yaks/spec/acceptance/json_shared_examples.rb +0 -8
- data/yaks/spec/acceptance/models.rb +0 -48
- data/yaks/spec/fixture_helpers.rb +0 -14
- data/yaks/spec/integration/map_to_resource_spec.rb +0 -28
- data/yaks/spec/json/confucius.collection.json +0 -28
- data/yaks/spec/json/confucius.hal.json +0 -59
- data/yaks/spec/json/confucius.json_api.json +0 -51
- data/yaks/spec/json/john.hal.json +0 -29
- data/yaks/spec/json/plant_collection.collection.json +0 -32
- data/yaks/spec/json/plant_collection.hal.json +0 -34
- data/yaks/spec/json/youtypeitwepostit.collection.json +0 -45
- data/yaks/spec/spec_helper.rb +0 -30
- data/yaks/spec/support/classes_for_policy_testing.rb +0 -36
- data/yaks/spec/support/deep_eql.rb +0 -123
- data/yaks/spec/support/fixtures.rb +0 -6
- data/yaks/spec/support/friends_mapper.rb +0 -29
- data/yaks/spec/support/models.rb +0 -23
- data/yaks/spec/support/pet_mapper.rb +0 -3
- data/yaks/spec/support/pet_peeve_mapper.rb +0 -3
- data/yaks/spec/support/shared_contexts.rb +0 -57
- data/yaks/spec/support/youtypeit_models_mappers.rb +0 -20
- data/yaks/spec/unit/yaks/collection_mapper_spec.rb +0 -165
- data/yaks/spec/unit/yaks/collection_resource_spec.rb +0 -77
- data/yaks/spec/unit/yaks/config/dsl_spec.rb +0 -87
- data/yaks/spec/unit/yaks/config_spec.rb +0 -74
- data/yaks/spec/unit/yaks/default_policy/derive_mapper_from_object_spec.rb +0 -80
- data/yaks/spec/unit/yaks/default_policy_spec.rb +0 -70
- data/yaks/spec/unit/yaks/format/collection_json_spec.rb +0 -41
- data/yaks/spec/unit/yaks/format/hal_spec.rb +0 -44
- data/yaks/spec/unit/yaks/format/json_api_spec.rb +0 -42
- data/yaks/spec/unit/yaks/format_spec.rb +0 -37
- data/yaks/spec/unit/yaks/fp/callable_spec.rb +0 -13
- data/yaks/spec/unit/yaks/fp/hash_updatable_spec.rb +0 -22
- data/yaks/spec/unit/yaks/fp/updatable_spec.rb +0 -22
- data/yaks/spec/unit/yaks/fp_spec.rb +0 -31
- data/yaks/spec/unit/yaks/mapper/association_mapper_spec.rb +0 -60
- data/yaks/spec/unit/yaks/mapper/association_spec.rb +0 -135
- data/yaks/spec/unit/yaks/mapper/attribute_spec.rb +0 -20
- data/yaks/spec/unit/yaks/mapper/class_methods_spec.rb +0 -67
- data/yaks/spec/unit/yaks/mapper/config_spec.rb +0 -166
- data/yaks/spec/unit/yaks/mapper/has_many_spec.rb +0 -89
- data/yaks/spec/unit/yaks/mapper/has_one_spec.rb +0 -51
- data/yaks/spec/unit/yaks/mapper/link_spec.rb +0 -196
- data/yaks/spec/unit/yaks/mapper_spec.rb +0 -303
- data/yaks/spec/unit/yaks/null_resource_spec.rb +0 -32
- data/yaks/spec/unit/yaks/primitivize_spec.rb +0 -77
- data/yaks/spec/unit/yaks/resource/link_spec.rb +0 -20
- data/yaks/spec/unit/yaks/resource_spec.rb +0 -108
- data/yaks/spec/unit/yaks/runner_spec.rb +0 -260
- data/yaks/spec/unit/yaks/util_spec.rb +0 -49
- data/yaks/spec/yaml/confucius.yaml +0 -28
- data/yaks/spec/yaml/youtypeitwepostit.yaml +0 -9
- data/yaks/yaks.gemspec +0 -41
@@ -1,45 +0,0 @@
|
|
1
|
-
module Yaks
|
2
|
-
class Primitivize
|
3
|
-
|
4
|
-
attr_reader :mappings
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@mappings = {}
|
8
|
-
end
|
9
|
-
|
10
|
-
def call(object)
|
11
|
-
mappings.each do |pattern, block|
|
12
|
-
return instance_exec(object, &block) if pattern === object
|
13
|
-
end
|
14
|
-
raise "don't know how to turn #{object.class} (#{object.inspect}) into a primitive"
|
15
|
-
end
|
16
|
-
|
17
|
-
def map(*types, &blk)
|
18
|
-
types.each do |type|
|
19
|
-
mappings[type] = blk
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.create
|
24
|
-
new.tap do |p|
|
25
|
-
p.map String, Numeric, true, false, nil do |object|
|
26
|
-
object
|
27
|
-
end
|
28
|
-
|
29
|
-
p.map Symbol do |object|
|
30
|
-
object.to_s
|
31
|
-
end
|
32
|
-
|
33
|
-
p.map Hash do |object|
|
34
|
-
object.to_enum.with_object({}) do |(key, value), output|
|
35
|
-
output[call(key)] = call(value)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
p.map Enumerable do |object|
|
40
|
-
object.map(&method(:call))
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/yaks/lib/yaks/resource.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
module Yaks
|
2
|
-
class Resource
|
3
|
-
include Equalizer.new(:type, :links, :attributes, :subresources)
|
4
|
-
include FP::HashUpdatable.new(:type, :links, :attributes, :subresources)
|
5
|
-
include Enumerable
|
6
|
-
|
7
|
-
attr_reader :type, :attributes, :links, :subresources
|
8
|
-
|
9
|
-
def initialize(options = {})
|
10
|
-
@type = options.fetch(:type, nil)
|
11
|
-
@attributes = options.fetch(:attributes, {})
|
12
|
-
@links = options.fetch(:links, [])
|
13
|
-
@subresources = options.fetch(:subresources, {})
|
14
|
-
end
|
15
|
-
|
16
|
-
def [](attr)
|
17
|
-
attributes[attr]
|
18
|
-
end
|
19
|
-
|
20
|
-
def each
|
21
|
-
return to_enum unless block_given?
|
22
|
-
yield self
|
23
|
-
end
|
24
|
-
|
25
|
-
def self_link
|
26
|
-
links.reverse.find do |link|
|
27
|
-
link.rel.equal? :self
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def collection?
|
32
|
-
false
|
33
|
-
end
|
34
|
-
|
35
|
-
def null_resource?
|
36
|
-
false
|
37
|
-
end
|
38
|
-
|
39
|
-
def update_attributes(new_attrs)
|
40
|
-
update(attributes: @attributes.merge(new_attrs))
|
41
|
-
end
|
42
|
-
|
43
|
-
def add_link(link)
|
44
|
-
update(links: @links + [link])
|
45
|
-
end
|
46
|
-
|
47
|
-
def add_subresource(rel, subresource)
|
48
|
-
update(subresources: @subresources.merge(rel => subresource))
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Yaks
|
2
|
-
class Resource
|
3
|
-
class Link
|
4
|
-
include Equalizer.new(:rel, :uri, :options)
|
5
|
-
|
6
|
-
attr_reader :rel, :uri, :options
|
7
|
-
|
8
|
-
def initialize(rel, uri, options)
|
9
|
-
@rel, @uri, @options = rel, uri, options
|
10
|
-
end
|
11
|
-
|
12
|
-
def title
|
13
|
-
options[:title]
|
14
|
-
end
|
15
|
-
|
16
|
-
def templated?
|
17
|
-
options.fetch(:templated) { false }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/yaks/lib/yaks/runner.rb
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
module Yaks
|
2
|
-
class Runner
|
3
|
-
include Util
|
4
|
-
include Anima.new(:object, :config, :options)
|
5
|
-
include Adamantium::Flat
|
6
|
-
extend Forwardable
|
7
|
-
|
8
|
-
def_delegators :config, :policy, :default_format, :format_options, :primitivize, :serializers, :hooks
|
9
|
-
|
10
|
-
def call
|
11
|
-
steps.inject(object) {|memo, (_, step)| step.call(memo) }
|
12
|
-
end
|
13
|
-
|
14
|
-
def context
|
15
|
-
{
|
16
|
-
policy: policy,
|
17
|
-
env: env,
|
18
|
-
mapper_stack: []
|
19
|
-
}.merge(slice_hash(options, :item_mapper))
|
20
|
-
end
|
21
|
-
memoize :context, freezer: :flat
|
22
|
-
|
23
|
-
def env
|
24
|
-
options.fetch(:env, {})
|
25
|
-
end
|
26
|
-
memoize :env, freezer: :noop
|
27
|
-
|
28
|
-
# @return [Class]
|
29
|
-
def format_class
|
30
|
-
Format.by_accept_header(env['HTTP_ACCEPT']) {
|
31
|
-
Format.by_name(options.fetch(:format) { default_format })
|
32
|
-
}
|
33
|
-
end
|
34
|
-
memoize :format_class
|
35
|
-
|
36
|
-
def steps
|
37
|
-
insert_hooks(
|
38
|
-
[[ :map, mapper ],
|
39
|
-
[ :format, formatter ],
|
40
|
-
[ :primitivize, primitivizer],
|
41
|
-
[ :serialize, serializer ]])
|
42
|
-
end
|
43
|
-
memoize :steps
|
44
|
-
|
45
|
-
def mapper
|
46
|
-
options.fetch(:mapper) do
|
47
|
-
policy.derive_mapper_from_object(object)
|
48
|
-
end.new(context)
|
49
|
-
end
|
50
|
-
memoize :mapper, freezer: :noop
|
51
|
-
|
52
|
-
def formatter
|
53
|
-
format_class.new(format_options[format_name])
|
54
|
-
end
|
55
|
-
memoize :formatter
|
56
|
-
|
57
|
-
def primitivizer
|
58
|
-
->(input) do
|
59
|
-
if format_class.serializer == :json
|
60
|
-
primitivize.call(input)
|
61
|
-
else
|
62
|
-
input
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
memoize :primitivizer
|
67
|
-
|
68
|
-
# @param [Hash] opts
|
69
|
-
# @return [String]
|
70
|
-
def format_name
|
71
|
-
options.fetch(:format) { default_format }
|
72
|
-
end
|
73
|
-
memoize :format_name
|
74
|
-
|
75
|
-
def serializer
|
76
|
-
serializers.fetch(format_class.serializer) do
|
77
|
-
policy.serializer_for_format(format_class)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
memoize :serializer
|
81
|
-
|
82
|
-
def insert_hooks(steps)
|
83
|
-
hooks.inject(steps) do |steps, (type, target_step, name, hook)|
|
84
|
-
steps.flat_map do |step_name, callable|
|
85
|
-
if step_name.eql? target_step
|
86
|
-
case type
|
87
|
-
when :before
|
88
|
-
[[name, hook], [step_name, callable]]
|
89
|
-
when :after
|
90
|
-
[[step_name, callable], [name, hook]]
|
91
|
-
when :around
|
92
|
-
[[step_name, ->(x) { hook.call(x, &callable) }]]
|
93
|
-
when :skip
|
94
|
-
[]
|
95
|
-
end
|
96
|
-
end || [[step_name, callable]]
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
data/yaks/lib/yaks/util.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
module Yaks
|
3
|
-
module Util
|
4
|
-
extend self
|
5
|
-
extend Forwardable
|
6
|
-
|
7
|
-
def_delegators Inflection, :singular, :singularize, :pluralize
|
8
|
-
|
9
|
-
def underscore(str)
|
10
|
-
str.gsub(/::/, '/')
|
11
|
-
.gsub(/(?<!^|\/)([A-Z])(?=[a-z$])|(?<=[a-z])([A-Z])/, '_\1\2')
|
12
|
-
.tr("-", "_")
|
13
|
-
.downcase
|
14
|
-
end
|
15
|
-
|
16
|
-
def camelize(str)
|
17
|
-
str.gsub(/\/(.?)/) { "::#{ $1.upcase }" }
|
18
|
-
.gsub!(/(?:^|_)(.)/) { $1.upcase }
|
19
|
-
end
|
20
|
-
|
21
|
-
def slice_hash(hash, *keys)
|
22
|
-
keys.each_with_object({}) {|k,dest| dest[k] = hash[k] if hash.key?(k) }
|
23
|
-
end
|
24
|
-
|
25
|
-
# Turn what is maybe a Proc into its result (or itself)
|
26
|
-
#
|
27
|
-
# When input can be either a value or a proc that returns a value,
|
28
|
-
# this conversion function can be used to resolve the thing to a
|
29
|
-
# value.
|
30
|
-
#
|
31
|
-
# The proc can be evaluated (instance_evaled) in a certain context,
|
32
|
-
# or evaluated as a closure.
|
33
|
-
#
|
34
|
-
# @param [Object|Proc] maybe_proc
|
35
|
-
# A proc or a plain value
|
36
|
-
# @param [Object] context
|
37
|
-
# (optional) A context used to instance_eval the proc
|
38
|
-
def Resolve(maybe_proc, context = nil)
|
39
|
-
if maybe_proc.is_a? Proc or maybe_proc.is_a? Method
|
40
|
-
if context
|
41
|
-
if maybe_proc.arity > 0
|
42
|
-
context.instance_eval(&maybe_proc)
|
43
|
-
else
|
44
|
-
# In case it's a lambda with zero arity instance_eval fails
|
45
|
-
context.instance_exec(&maybe_proc)
|
46
|
-
end
|
47
|
-
else
|
48
|
-
maybe_proc.()
|
49
|
-
end
|
50
|
-
else
|
51
|
-
maybe_proc
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
data/yaks/lib/yaks/version.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'acceptance/models'
|
4
|
-
require 'acceptance/json_shared_examples'
|
5
|
-
|
6
|
-
RSpec.describe Yaks::Format::Hal do
|
7
|
-
yaks_rel_template = Yaks.new do
|
8
|
-
format_options :hal, plural_links: ['http://literature.example.com/rels/quotes']
|
9
|
-
rel_template "http://literature.example.com/rel/{association_name}"
|
10
|
-
skip :serialize
|
11
|
-
end
|
12
|
-
|
13
|
-
yaks_policy_dsl = Yaks.new do
|
14
|
-
format_options :hal, plural_links: ['http://literature.example.com/rels/quotes']
|
15
|
-
derive_rel_from_association do |association|
|
16
|
-
"http://literature.example.com/rel/#{association.name}"
|
17
|
-
end
|
18
|
-
skip :serialize
|
19
|
-
end
|
20
|
-
|
21
|
-
include_examples 'JSON output format' , yaks_rel_template , :hal , 'confucius'
|
22
|
-
include_examples 'JSON output format' , yaks_policy_dsl , :hal , 'confucius'
|
23
|
-
end
|
24
|
-
|
25
|
-
RSpec.describe Yaks::Format::JsonAPI do
|
26
|
-
config = Yaks.new do
|
27
|
-
default_format :json_api
|
28
|
-
skip :serialize
|
29
|
-
end
|
30
|
-
|
31
|
-
include_examples 'JSON output format' , config , :json_api , 'confucius'
|
32
|
-
end
|
33
|
-
|
34
|
-
RSpec.describe Yaks::Format::CollectionJson do
|
35
|
-
youtypeit_yaks = Yaks.new do
|
36
|
-
default_format :collection_json
|
37
|
-
namespace Youtypeitwepostit
|
38
|
-
skip :serialize
|
39
|
-
end
|
40
|
-
|
41
|
-
confucius_yaks = Yaks.new do
|
42
|
-
default_format :collection_json
|
43
|
-
skip :serialize
|
44
|
-
end
|
45
|
-
|
46
|
-
include_examples 'JSON output format', youtypeit_yaks, :collection, 'youtypeitwepostit'
|
47
|
-
include_examples 'JSON output format', confucius_yaks, :collection, 'confucius'
|
48
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'anima'
|
2
|
-
|
3
|
-
class Scholar
|
4
|
-
include Anima.new(:id, :name, :pinyin, :latinized, :works)
|
5
|
-
end
|
6
|
-
|
7
|
-
class Work
|
8
|
-
include Anima.new(:id, :chinese_name, :english_name, :quotes, :era)
|
9
|
-
end
|
10
|
-
|
11
|
-
class Quote
|
12
|
-
include Anima.new(:id, :chinese, :english, :sources)
|
13
|
-
end
|
14
|
-
|
15
|
-
class Era
|
16
|
-
include Anima.new(:id, :name)
|
17
|
-
end
|
18
|
-
|
19
|
-
class LiteratureBaseMapper < Yaks::Mapper
|
20
|
-
link :profile, 'http://literature.example.com/profiles/{mapper_name}', expand: true
|
21
|
-
link :self, 'http://literature.example.com/{mapper_name}/{id}'
|
22
|
-
end
|
23
|
-
|
24
|
-
class ScholarMapper < LiteratureBaseMapper
|
25
|
-
attributes :id, :name, :pinyin, :latinized
|
26
|
-
has_many :works
|
27
|
-
|
28
|
-
link 'http://literature.example.com/rels/quotes', 'http://literature.example.com/quotes/?author={downcased_pinyin}&q={query}', expand: [:downcased_pinyin], title: 'Search for quotes'
|
29
|
-
link :self, 'http://literature.example.com/authors/{downcased_pinyin}'
|
30
|
-
|
31
|
-
def downcased_pinyin
|
32
|
-
object.pinyin.downcase
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class WorkMapper < LiteratureBaseMapper
|
37
|
-
attributes :id, :chinese_name, :english_name
|
38
|
-
has_many :quotes
|
39
|
-
has_one :era
|
40
|
-
end
|
41
|
-
|
42
|
-
class QuoteMapper < Yaks::Mapper
|
43
|
-
attributes :id, :chinese
|
44
|
-
end
|
45
|
-
|
46
|
-
class EraMapper < Yaks::Mapper
|
47
|
-
attributes :id, :name
|
48
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
module FixtureHelpers
|
5
|
-
module_function
|
6
|
-
|
7
|
-
def load_json_fixture(name)
|
8
|
-
JSON.parse(Yaks::Root.join('spec/json', name + '.json').read)
|
9
|
-
end
|
10
|
-
|
11
|
-
def load_yaml_fixture(name)
|
12
|
-
YAML.load(Yaks::Root.join('spec/yaml', name + '.yaml').read)
|
13
|
-
end
|
14
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe 'Mapping domain models to Resource objects' do
|
4
|
-
include_context 'fixtures'
|
5
|
-
include_context 'yaks context'
|
6
|
-
|
7
|
-
subject { mapper.call(john) }
|
8
|
-
let(:mapper) { FriendMapper.new(yaks_context) }
|
9
|
-
|
10
|
-
it { should be_a Yaks::Resource }
|
11
|
-
its(:type) { should eql 'friend' }
|
12
|
-
its(:attributes) { should eql(id: 1, name: 'john') }
|
13
|
-
its(:links) { should eql [ Yaks::Resource::Link.new(:copyright, '/api/copyright/2024', {}) ] }
|
14
|
-
|
15
|
-
its(:subresources) {
|
16
|
-
should eq(
|
17
|
-
"rel:pet_peeve" => Yaks::Resource.new(type:'pet_peeve', attributes: {id: 4, type: 'parsing with regexps'}),
|
18
|
-
"rel:pets" => Yaks::CollectionResource.new(
|
19
|
-
type: 'pet',
|
20
|
-
members: [
|
21
|
-
Yaks::Resource.new(type: 'pet', attributes: {:id => 2, :species => "dog", :name => "boingboing"}),
|
22
|
-
Yaks::Resource.new(type: 'pet', attributes: {:id => 3, :species => "cat", :name => "wassup"})
|
23
|
-
],
|
24
|
-
collection_rel: 'rel:pets'
|
25
|
-
)
|
26
|
-
)
|
27
|
-
}
|
28
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"collection": {
|
3
|
-
"version": "1.0",
|
4
|
-
"href": "http://literature.example.com/authors/kongzi",
|
5
|
-
"items": [
|
6
|
-
{
|
7
|
-
"href": "http://literature.example.com/authors/kongzi",
|
8
|
-
"data": [
|
9
|
-
{ "name": "id", "value": 9 },
|
10
|
-
{ "name": "name", "value": "孔子" },
|
11
|
-
{ "name": "pinyin", "value": "Kongzi" },
|
12
|
-
{ "name": "latinized", "value": "Confucius" }
|
13
|
-
],
|
14
|
-
"links": [
|
15
|
-
{
|
16
|
-
"rel": "profile",
|
17
|
-
"href": "http://literature.example.com/profiles/scholar"
|
18
|
-
},
|
19
|
-
{
|
20
|
-
"name": "Search for quotes",
|
21
|
-
"rel": "http://literature.example.com/rels/quotes",
|
22
|
-
"href": "http://literature.example.com/quotes/?author=kongzi&q={query}"
|
23
|
-
}
|
24
|
-
]
|
25
|
-
}
|
26
|
-
]
|
27
|
-
}
|
28
|
-
}
|