Module: Lp::Serializable

Includes:
Strategies
Defined in:
lib/lp/serializable.rb,
lib/lp/serializable/version.rb,
lib/lp/serializable/utilities.rb,
lib/lp/serializable/strategies.rb

Defined Under Namespace

Modules: Strategies, Utilities Classes: UnserializableCollection

Constant Summary collapse

VERSION =
"0.2.0"

Constants included from FastJsonapi

FastJsonapi::MandatoryField

Instance Method Summary collapse

Instance Method Details

#serialize_and_flatten(resource, options = {}) ⇒ Object



13
14
15
16
# File 'lib/lp/serializable.rb', line 13

def serialize_and_flatten(resource, options={})
  base_hash = serialize_hash(resource)
  flatten_and_nest_data(base_hash, set_nested_option(options))
end

#serialize_and_flatten_collection(resource, class_name, options = {}) ⇒ Object



26
27
28
29
30
31
# File 'lib/lp/serializable.rb', line 26

def serialize_and_flatten_collection(resource, class_name, options={})
  base_hash = serializable_hash_with_class_name(resource, 
                                                class_name, 
                                                options)
  flatten_array_and_nest_data(base_hash, set_nested_option(options))
end

#serialize_and_flatten_with_class_name(resource, class_name, options = {}) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/lp/serializable.rb', line 18

def serialize_and_flatten_with_class_name(resource, class_name, options={})
  raise UnserializableCollection if resource.is_a?(Array) 
  base_hash = serializable_hash_with_class_name(resource, 
                                                class_name, 
                                                options)
  flatten_and_nest_data(base_hash, set_nested_option(options))
end