Module: USerializer
- Defined in:
- lib/userializer.rb,
lib/userializer/has_one.rb,
lib/userializer/version.rb,
lib/userializer/has_many.rb,
lib/userializer/attribute.rb,
lib/userializer/base_serializer.rb,
lib/userializer/array_serializer.rb,
lib/userializer/composite_serializer.rb
Defined Under Namespace
Classes: ArraySerializer, Attribute, BaseSerializer, CompositeObject, CompositeSerializer, HasMany, HasOne, HeterogeneousArray
Constant Summary
collapse
- NS_SEPARATOR =
'::'.freeze
- VERSION =
"0.3.4"
Class Method Summary
collapse
Class Method Details
.infered_serializer_class(kls) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/userializer.rb', line 16
def infered_serializer_class(kls)
return nil if kls.nil?
(kls.name + 'Serializer').split(NS_SEPARATOR).inject(Object) do |o, c|
o.const_get(c)
end
end
|
.serializer_for(obj) ⇒ Object
10
11
12
13
14
|
# File 'lib/userializer.rb', line 10
def serializer_for(obj)
return nil if obj.nil?
infered_serializer_class(obj.class)
end
|