Module: Serega::SeregaAttributeNormalizer::AttributeNormalizerInstanceMethods

Included in:
Serega::SeregaAttributeNormalizer
Defined in:
lib/serega/attribute_normalizer.rb

Overview

AttributeNormalizer instance methods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#init_blockHash (readonly)

Attribute initial params

Returns:

  • (Hash)

    Attribute initial params



14
15
16
# File 'lib/serega/attribute_normalizer.rb', line 14

def init_block
  @init_block
end

#init_nameHash (readonly)

Attribute initial params

Returns:

  • (Hash)

    Attribute initial params



14
15
16
# File 'lib/serega/attribute_normalizer.rb', line 14

def init_name
  @init_name
end

#init_optsHash (readonly)

Attribute initial params

Returns:

  • (Hash)

    Attribute initial params



14
15
16
# File 'lib/serega/attribute_normalizer.rb', line 14

def init_opts
  @init_opts
end

Instance Method Details

#hideBoolean?

Shows if attribute is specified to be hidden

Returns:

  • (Boolean, nil)

    if attribute must be hidden by default



62
63
64
65
66
# File 'lib/serega/attribute_normalizer.rb', line 62

def hide
  return @hide if instance_variable_defined?(:@hide)

  @hide = prepare_hide
end

#initialize(initials) ⇒ SeregaAttributeNormalizer

Instantiates attribute options normalizer

Parameters:

  • initials (Hash)

    new attribute options

Returns:



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

#keySymbol

Symbolized initial attribute key or attribute name if key is empty

Returns:

  • (Symbol)

    Attribute normalized name



43
44
45
# File 'lib/serega/attribute_normalizer.rb', line 43

def key
  @key ||= prepare_key
end

#manyBoolean?

Shows if attribute is specified to be a one-to-many relationship

Returns:

  • (Boolean, nil)

    if attribute is specified to be a one-to-many relationship



73
74
75
76
77
# File 'lib/serega/attribute_normalizer.rb', line 73

def many
  return @many if instance_variable_defined?(:@many)

  @many = prepare_many
end

#nameSymbol

Symbolized initial attribute name

Returns:

  • (Symbol)

    Attribute normalized name



34
35
36
# File 'lib/serega/attribute_normalizer.rb', line 34

def name
  @name ||= prepare_name
end

#serializerSerega, ...

Shows specified attribute serializer

Returns:

  • (Serega, String, #callable, nil)

    specified serializer



83
84
85
86
87
# File 'lib/serega/attribute_normalizer.rb', line 83

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

Returns:

  • (#call)

    Attribute normalized callable value block



53
54
55
# File 'lib/serega/attribute_normalizer.rb', line 53

def value_block
  @value_block ||= prepare_value_block
end