Module: RestPack::Serializer
- Extended by:
- ActiveSupport::Concern
- Includes:
- Attributes, Filterable, Paging, Resource, SideLoading, Single
- Defined in:
- lib/restpack_serializer.rb,
lib/restpack_serializer/result.rb,
lib/restpack_serializer/options.rb,
lib/restpack_serializer/version.rb,
lib/restpack_serializer/serializable.rb,
lib/restpack_serializer/configuration.rb
Defined Under Namespace
Modules: Attributes, ClassMethods, Filterable, Paging, Resource, SideLoading, Single
Classes: Configuration, Factory, InvalidInclude, Options, Result
Constant Summary
collapse
- VERSION =
'0.4.13'
- @@config =
Configuration.new
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Attributes
#default_href
Class Method Details
.setup {|@@config| ... } ⇒ Object
15
16
17
|
# File 'lib/restpack_serializer.rb', line 15
def self.setup
yield @@config
end
|
Instance Method Details
#as_json(model, context = {}) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/restpack_serializer/serializable.rb', line 31
def as_json(model, context = {})
@model, @context = model, context
data = {}
if self.class.serializable_attributes.present?
self.class.serializable_attributes.each do |key, name|
data[key] = self.send(name) if include_attribute?(name)
end
end
add_custom_attributes(data)
add_links(model, data)
data
end
|
#custom_attributes ⇒ Object
47
48
49
|
# File 'lib/restpack_serializer/serializable.rb', line 47
def custom_attributes
{}
end
|