Class: ActiveModel::Serializer::LazyAssociation Private
- Inherits:
-
Struct
- Object
- Struct
- ActiveModel::Serializer::LazyAssociation
- Defined in:
- lib/active_model/serializer/lazy_association.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- REFLECTION_OPTIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%i(key links polymorphic meta serializer virtual_value namespace).freeze
Instance Attribute Summary collapse
-
#association_options ⇒ Object
Returns the value of attribute association_options.
-
#reflection ⇒ Object
Returns the value of attribute reflection.
Instance Method Summary collapse
- #include_data? ⇒ Boolean private
- #object ⇒ Object (also: #eval_reflection_block) private
- #reflection_options ⇒ Object private
- #serializer ⇒ ActiveModel::Serializer? private
- #serializer_class ⇒ Object private
- #virtual_value ⇒ Object private
Instance Attribute Details
#association_options ⇒ Object
Returns the value of attribute association_options
4 5 6 |
# File 'lib/active_model/serializer/lazy_association.rb', line 4 def @association_options end |
#reflection ⇒ Object
Returns the value of attribute reflection
4 5 6 |
# File 'lib/active_model/serializer/lazy_association.rb', line 4 def reflection @reflection end |
Instance Method Details
#include_data? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 24 25 26 |
# File 'lib/active_model/serializer/lazy_association.rb', line 21 def include_data? eval_reflection_block if reflection.block reflection.include_data?( .fetch(:include_slice) ) end |
#object ⇒ Object Also known as: eval_reflection_block
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 16 17 18 |
# File 'lib/active_model/serializer/lazy_association.rb', line 13 def object @object ||= reflection.value( .fetch(:parent_serializer), .fetch(:include_slice) ) end |
#reflection_options ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/active_model/serializer/lazy_association.rb', line 9 def @reflection_options ||= reflection..dup.reject { |k, _| !REFLECTION_OPTIONS.include?(k) } end |
#serializer ⇒ ActiveModel::Serializer?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 32 33 34 35 36 37 |
# File 'lib/active_model/serializer/lazy_association.rb', line 29 def serializer return @serializer if defined?(@serializer) if serializer_class serialize_object!(object) elsif !object.nil? && !object.instance_of?(Object) cached_result[:virtual_value] = object end @serializer = cached_result[:serializer] end |
#serializer_class ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 46 47 48 |
# File 'lib/active_model/serializer/lazy_association.rb', line 43 def serializer_class return @serializer_class if defined?(@serializer_class) = { namespace: namespace } [:serializer] = [:serializer] if .key?(:serializer) @serializer_class = .fetch(:parent_serializer).class.serializer_for(object, ) end |
#virtual_value ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 |
# File 'lib/active_model/serializer/lazy_association.rb', line 39 def virtual_value cached_result[:virtual_value] || [:virtual_value] end |