Module: Lp::Serializable
- Includes:
- Exceptions, Strategies
- Defined in:
- lib/lp/serializable.rb,
lib/lp/serializable/version.rb,
lib/lp/serializable/utilities.rb,
lib/lp/serializable/exceptions.rb,
lib/lp/serializable/strategies.rb
Defined Under Namespace
Modules: Exceptions, Strategies, Utilities
Constant Summary
collapse
- VERSION =
"0.2.2"
Constants included
from FastJsonapi
FastJsonapi::MandatoryField
Instance Method Summary
collapse
Instance Method Details
#serialize_and_flatten(resource, options = {}) ⇒ Object
Also known as:
serializable
9
10
11
12
13
|
# File 'lib/lp/serializable.rb', line 9
def serialize_and_flatten(resource, options = {})
collection_option = collection?(false)
base_hash = serialize_hash(resource, options.merge(collection_option))
flatten_and_nest_data(base_hash, set_nested_option(options))
end
|
#serialize_and_flatten_collection(resource, class_name, options = {}) ⇒ Object
Also known as:
serializable_collection
30
31
32
33
34
35
36
37
38
|
# File 'lib/lp/serializable.rb', line 30
def serialize_and_flatten_collection(resource, class_name, options = {})
collection_option = collection?(true)
base_hash = serializable_hash_with_class_name(
resource,
class_name,
options.merge(collection_option),
)
flatten_array_and_nest_data(base_hash, set_nested_option(options))
end
|
#serialize_and_flatten_with_class_name(resource, class_name, options = {}) ⇒ Object
Also known as:
serializable_class
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/lp/serializable.rb', line 15
def serialize_and_flatten_with_class_name(
resource,
class_name,
options = {}
)
raise UnserializableCollection if resource.is_a?(Array)
collection_option = collection?(false)
base_hash = serializable_hash_with_class_name(
resource,
class_name,
options.merge(collection_option),
)
flatten_and_nest_data(base_hash, set_nested_option(options))
end
|