Module: Serega::SeregaAttributeNormalizer::AttributeNormalizerInstanceMethods
- Included in:
- Serega::SeregaAttributeNormalizer
- Defined in:
- lib/serega/attribute_normalizer.rb
Overview
AttributeNormalizer instance methods
Instance Attribute Summary collapse
-
#init_block ⇒ Hash
readonly
Attribute initial params.
-
#init_name ⇒ Hash
readonly
Attribute initial params.
-
#init_opts ⇒ Hash
readonly
Attribute initial params.
Instance Method Summary collapse
-
#batch_loaders ⇒ Array<Symbol>
Shows specified batch loaders names.
-
#default ⇒ Object
Shows the default attribute value.
-
#hide ⇒ Boolean?
Shows if attribute is specified to be hidden.
-
#initialize(initials) ⇒ SeregaAttributeNormalizer
Instantiates attribute options normalizer.
-
#many ⇒ Boolean?
Shows if attribute is specified to be a one-to-many relationship.
-
#method_name ⇒ Symbol
Symbolized initial attribute method name.
-
#name ⇒ Symbol
Symbolized initial attribute name.
-
#preloads ⇒ Hash?
Shows normalized preloads for current attribute.
-
#preloads_path ⇒ Array
Shows normalized preloads_path for current attribute.
-
#serializer ⇒ Serega, ...
Shows specified attribute serializer.
-
#value_block ⇒ #call
Combines all options to return single block that will be used to find attribute value during serialization.
-
#value_block_signature ⇒ String
Detects value block parameters signature.
Instance Attribute Details
#init_block ⇒ Hash (readonly)
Attribute initial params
14 15 16 |
# File 'lib/serega/attribute_normalizer.rb', line 14 def init_block @init_block end |
#init_name ⇒ Hash (readonly)
Attribute initial params
14 15 16 |
# File 'lib/serega/attribute_normalizer.rb', line 14 def init_name @init_name end |
#init_opts ⇒ Hash (readonly)
Attribute initial params
14 15 16 |
# File 'lib/serega/attribute_normalizer.rb', line 14 def init_opts @init_opts end |
Instance Method Details
#batch_loaders ⇒ Array<Symbol>
Shows specified batch loaders names
136 137 138 |
# File 'lib/serega/attribute_normalizer.rb', line 136 def batch_loaders @batch_loaders ||= prepare_batch_loaders end |
#default ⇒ Object
Shows the default attribute value. It is a value that replaces found nils.
When custom :default is not specified, we set empty array as default when ‘many: true` specified
105 106 107 108 109 |
# File 'lib/serega/attribute_normalizer.rb', line 105 def default return @default if instance_variable_defined?(:@default) @default = prepare_default end |
#hide ⇒ Boolean?
Shows if attribute is specified to be hidden
71 72 73 74 75 |
# File 'lib/serega/attribute_normalizer.rb', line 71 def hide return @hide if instance_variable_defined?(:@hide) @hide = prepare_hide end |
#initialize(initials) ⇒ SeregaAttributeNormalizer
Instantiates attribute options normalizer
23 24 25 26 27 |
# File 'lib/serega/attribute_normalizer.rb', line 23 def initialize(initials) @init_name = initials[:name] @init_opts = initials[:opts] @init_block = initials[:block] end |
#many ⇒ Boolean?
Shows if attribute is specified to be a one-to-many relationship
82 83 84 85 86 |
# File 'lib/serega/attribute_normalizer.rb', line 82 def many return @many if instance_variable_defined?(:@many) @many = prepare_many end |
#method_name ⇒ Symbol
Symbolized initial attribute method name
43 44 45 |
# File 'lib/serega/attribute_normalizer.rb', line 43 def method_name @method_name ||= prepare_method_name end |
#name ⇒ Symbol
Symbolized initial attribute name
34 35 36 |
# File 'lib/serega/attribute_normalizer.rb', line 34 def name @name ||= prepare_name end |
#preloads ⇒ Hash?
Shows normalized preloads for current attribute
116 117 118 119 120 |
# File 'lib/serega/attribute_normalizer.rb', line 116 def preloads return @preloads if instance_variable_defined?(:@preloads) @preloads = prepare_preloads end |
#preloads_path ⇒ Array
Shows normalized preloads_path for current attribute
127 128 129 130 131 |
# File 'lib/serega/attribute_normalizer.rb', line 127 def preloads_path return @preloads_path if instance_variable_defined?(:@preloads_path) @preloads_path = prepare_preloads_path end |
#serializer ⇒ Serega, ...
Shows specified attribute serializer
92 93 94 95 96 |
# File 'lib/serega/attribute_normalizer.rb', line 92 def serializer return @serializer if instance_variable_defined?(:@serializer) @serializer = prepare_serializer end |
#value_block ⇒ #call
Combines all options to return single block that will be used to find attribute value during serialization
53 54 55 |
# File 'lib/serega/attribute_normalizer.rb', line 53 def value_block @value_block ||= prepare_value_block end |
#value_block_signature ⇒ String
Detects value block parameters signature
62 63 64 |
# File 'lib/serega/attribute_normalizer.rb', line 62 def value_block_signature @value_block_signature ||= SeregaUtils::MethodSignature.call(value_block, pos_limit: 2, keyword_args: [:ctx]) end |