Class: ViewModel::Record::AttributeData

Inherits:
Object
  • Object
show all
Defined in:
lib/view_model/record/attribute_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, model_attr_name:, attribute_viewmodel:, attribute_serializer:, array:, read_only:, write_once:) ⇒ AttributeData

Returns a new instance of AttributeData.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/view_model/record/attribute_data.rb', line 6

def initialize(name:,
               model_attr_name:,
               attribute_viewmodel:,
               attribute_serializer:,
               array:,
               read_only:,
               write_once:)
  @name                 = name
  @model_attr_name      = model_attr_name
  @attribute_viewmodel  = attribute_viewmodel
  @attribute_serializer = attribute_serializer
  @array                = array
  @read_only            = read_only
  @write_once           = write_once
end

Instance Attribute Details

#attribute_serializerObject (readonly)

Returns the value of attribute attribute_serializer.



4
5
6
# File 'lib/view_model/record/attribute_data.rb', line 4

def attribute_serializer
  @attribute_serializer
end

#attribute_viewmodelObject (readonly)

Returns the value of attribute attribute_viewmodel.



4
5
6
# File 'lib/view_model/record/attribute_data.rb', line 4

def attribute_viewmodel
  @attribute_viewmodel
end

#model_attr_nameObject (readonly)

Returns the value of attribute model_attr_name.



4
5
6
# File 'lib/view_model/record/attribute_data.rb', line 4

def model_attr_name
  @model_attr_name
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/view_model/record/attribute_data.rb', line 4

def name
  @name
end

Instance Method Details

#array?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/view_model/record/attribute_data.rb', line 26

def array?
  @array
end

#association?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/view_model/record/attribute_data.rb', line 22

def association?
  false
end

#map_value(value) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/view_model/record/attribute_data.rb', line 46

def map_value(value)
  if array?
    value.map { |v| yield(v) }
  else
    yield(value)
  end
end

#read_only?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/view_model/record/attribute_data.rb', line 30

def read_only?
  @read_only
end

#using_serializer?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/view_model/record/attribute_data.rb', line 38

def using_serializer?
  !@attribute_serializer.nil?
end

#using_viewmodel?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/view_model/record/attribute_data.rb', line 42

def using_viewmodel?
  !@attribute_viewmodel.nil?
end

#write_once?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/view_model/record/attribute_data.rb', line 34

def write_once?
  @write_once
end