module Lp::Serializable
Constants
- VERSION
Public Instance Methods
serializable_class( resource, class_name, options = {} )
Alias for: serialize_and_flatten_with_class_name
serializable_collection(resource, class_name, options = {})
Alias for: serialize_and_flatten_collection
serialize_and_flatten(resource, options = {})
click to toggle source
# File lib/lp/serializable.rb, line 9 def serialize_and_flatten(resource, options = {}) return { :data => nil } if resource.nil? # Match the return of serializable_class when given nil collection_option = collection?(false) base_hash = serialize_hash(resource, options.merge(collection_option)) flatten_and_nest_data(base_hash, set_nested_option(options)) end
Also aliased as: serializable
serialize_and_flatten_collection(resource, class_name, options = {})
click to toggle source
# File lib/lp/serializable.rb, line 31 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
Also aliased as: serializable_collection
serialize_and_flatten_with_class_name( resource, class_name, options = {} )
click to toggle source
# File lib/lp/serializable.rb, line 16 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
Also aliased as: serializable_class