Class: CollectionJson::Serializer
- Inherits:
-
Object
- Object
- CollectionJson::Serializer
show all
- Defined in:
- lib/collection_json_serializer/builder.rb,
lib/collection_json_serializer/support.rb,
lib/collection_json_serializer/version.rb,
lib/collection_json_serializer/validator.rb,
lib/collection_json_serializer/serializer.rb,
lib/collection_json_serializer/objects/item.rb,
lib/collection_json_serializer/objects/query.rb,
lib/collection_json_serializer/validator/url.rb,
lib/collection_json_serializer/validator/value.rb,
lib/collection_json_serializer/objects/template.rb
Defined Under Namespace
Modules: Support
Classes: Builder, Objects, Validator
Constant Summary
collapse
- VERSION =
"0.2.0"
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(resource) ⇒ Serializer
Returns a new instance of Serializer.
41
42
43
44
45
46
47
|
# File 'lib/collection_json_serializer/serializer.rb', line 41
def initialize(resource)
@resources = if resource.respond_to? :to_ary
resource
else
[resource]
end
end
|
Class Attribute Details
.attributes(*attrs) ⇒ Object
Returns the value of attribute attributes.
5
6
7
|
# File 'lib/collection_json_serializer/serializer.rb', line 5
def attributes
@attributes
end
|
.href(*attrs) ⇒ Object
Returns the value of attribute href.
4
5
6
|
# File 'lib/collection_json_serializer/serializer.rb', line 4
def href
@href
end
|
.links(*attrs) ⇒ Object
Returns the value of attribute links.
7
8
9
|
# File 'lib/collection_json_serializer/serializer.rb', line 7
def links
@links
end
|
.queries(*attrs) ⇒ Object
Returns the value of attribute queries.
8
9
10
|
# File 'lib/collection_json_serializer/serializer.rb', line 8
def queries
@queries
end
|
.template(*attrs) ⇒ Object
Returns the value of attribute template.
6
7
8
|
# File 'lib/collection_json_serializer/serializer.rb', line 6
def template
@template
end
|
Instance Attribute Details
#resources ⇒ Object
Returns the value of attribute resources.
39
40
41
|
# File 'lib/collection_json_serializer/serializer.rb', line 39
def resources
@resources
end
|
Class Method Details
.inherited(base) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/collection_json_serializer/serializer.rb', line 11
def self.inherited(base)
base.href = []
base.attributes = []
base.template = []
base.links = []
base.queries = []
end
|
Instance Method Details
#attributes ⇒ Object
53
54
55
|
# File 'lib/collection_json_serializer/serializer.rb', line 53
def attributes
self.class.attributes
end
|
#errors ⇒ Object
77
78
79
|
# File 'lib/collection_json_serializer/serializer.rb', line 77
def errors
Validator.new(self).errors
end
|
#href ⇒ Object
49
50
51
|
# File 'lib/collection_json_serializer/serializer.rb', line 49
def href
self.class.href.first
end
|
#invalid? ⇒ Boolean
69
70
71
|
# File 'lib/collection_json_serializer/serializer.rb', line 69
def invalid?
Validator.new(self).invalid?
end
|
#links ⇒ Object
61
62
63
|
# File 'lib/collection_json_serializer/serializer.rb', line 61
def links
self.class.links
end
|
#queries ⇒ Object
65
66
67
|
# File 'lib/collection_json_serializer/serializer.rb', line 65
def queries
self.class.queries
end
|
#template ⇒ Object
57
58
59
|
# File 'lib/collection_json_serializer/serializer.rb', line 57
def template
self.class.template
end
|
#valid? ⇒ Boolean
73
74
75
|
# File 'lib/collection_json_serializer/serializer.rb', line 73
def valid?
Validator.new(self).valid?
end
|