Class: Uchi::Field::Base::Component

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/uchi/field/base.rb

Direct Known Subclasses

Edit, Index, Show

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field:, record:, repository:) ⇒ Component

Returns a new instance of Component.



9
10
11
12
13
14
15
# File 'app/components/uchi/field/base.rb', line 9

def initialize(field:, record:, repository:)
  super()

  @field = field
  @record = record
  @repository = repository
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



7
8
9
# File 'app/components/uchi/field/base.rb', line 7

def field
  @field
end

#recordObject (readonly)

Returns the value of attribute record.



7
8
9
# File 'app/components/uchi/field/base.rb', line 7

def record
  @record
end

#repositoryObject (readonly)

Returns the value of attribute repository.



7
8
9
# File 'app/components/uchi/field/base.rb', line 7

def repository
  @repository
end

Instance Method Details

#valueObject

Returns the raw value of the field as returned by the field's value method.



19
20
21
22
23
# File 'app/components/uchi/field/base.rb', line 19

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

  @value = field.value(record)
end