Class: Uchi::Field
- Inherits:
-
Object
show all
- Includes:
- Configuration
- Defined in:
- lib/uchi/field.rb,
app/components/uchi/field/id.rb,
lib/uchi/field/configuration.rb,
app/components/uchi/field/base.rb,
app/components/uchi/field/date.rb,
app/components/uchi/field/file.rb,
app/components/uchi/field/text.rb,
app/components/uchi/field/blank.rb,
app/components/uchi/field/image.rb,
app/components/uchi/field/number.rb,
app/components/uchi/field/string.rb,
app/components/uchi/field/boolean.rb,
app/components/uchi/field/has_many.rb,
app/components/uchi/field/date_time.rb,
app/components/uchi/field/belongs_to.rb,
app/components/uchi/field/has_and_belongs_to_many.rb
Direct Known Subclasses
Base, BelongsTo, Blank, Boolean, Date, DateTime, File, HasAndBelongsToMany, HasMany, Image, Number, String, Text
Defined Under Namespace
Modules: Configuration
Classes: Base, BelongsTo, Blank, Boolean, Date, DateTime, File, HasAndBelongsToMany, HasMany, Id, Image, Number, String, Text
Constant Summary
Configuration::DEFAULT_READER
Instance Attribute Summary collapse
Instance Method Summary
collapse
#on, #reader, #searchable, #searchable?, #sortable, #sortable?
Constructor Details
#initialize(name) ⇒ Field
Returns a new instance of Field.
49
50
51
52
|
# File 'lib/uchi/field.rb', line 49
def initialize(name)
super()
@name = name.to_sym
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
9
10
11
|
# File 'lib/uchi/field.rb', line 9
def name
@name
end
|
#repository ⇒ Object
The repository this field is associated with.
12
13
14
|
# File 'lib/uchi/field.rb', line 12
def repository
@repository
end
|
Instance Method Details
#column_name ⇒ Object
14
15
16
|
# File 'lib/uchi/field.rb', line 14
def column_name
name.to_s.humanize
end
|
#edit_component(form:, repository:, label: nil, hint: nil) ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/uchi/field.rb', line 22
def edit_component(form:, repository:, label: nil, hint: nil)
edit_component_class.new(
field: self,
form: form,
repository: repository,
label: label,
hint: hint
)
end
|
#edit_component_class ⇒ Object
32
33
34
|
# File 'lib/uchi/field.rb', line 32
def edit_component_class
self.class.const_get(:Edit)
end
|
#group_as(_action) ⇒ Object
18
19
20
|
# File 'lib/uchi/field.rb', line 18
def group_as(_action)
:attributes
end
|
#index_component(record:, repository:) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/uchi/field.rb', line 36
def index_component(record:, repository:)
index_component_class.new(
field: self,
record: record,
repository: repository
)
end
|
#index_component_class ⇒ Object
44
45
46
|
# File 'lib/uchi/field.rb', line 44
def index_component_class
self.class.const_get(:Index)
end
|
#param_key ⇒ Object
Returns the key that this field is expected to use in params
55
56
57
|
# File 'lib/uchi/field.rb', line 55
def param_key
name.to_sym
end
|
#permitted_param ⇒ Object
Returns the values to use for permitting this field in strong parameters
60
61
62
|
# File 'lib/uchi/field.rb', line 60
def permitted_param
param_key
end
|
#show_component(record:, repository:) ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/uchi/field.rb', line 64
def show_component(record:, repository:)
show_component_class.new(
field: self,
record: record,
repository: repository
)
end
|
#show_component_class ⇒ Object
72
73
74
|
# File 'lib/uchi/field.rb', line 72
def show_component_class
self.class.const_get(:Show)
end
|
#value(record) ⇒ Object
76
77
78
|
# File 'lib/uchi/field.rb', line 76
def value(record)
reader.call(record, name)
end
|