Class: Oversee::Field

Inherits:
Base
  • Object
show all
Defined in:
app/components/oversee/field.rb

Direct Known Subclasses

Display, Form, Input, Label, Set

Defined Under Namespace

Classes: Display, Form, Input, Label, Set, Value

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource: nil, key: nil, value: nil, datatype: nil, **options) ⇒ Field

Returns a new instance of Field.



7
8
9
10
11
12
13
# File 'app/components/oversee/field.rb', line 7

def initialize(resource: nil, key: nil, value: nil, datatype: nil, **options)
  @resource = resource
  @key = key
  @value = value
  @datatype = datatype
  @options = options
end

Instance Attribute Details

#datatypeObject (readonly)

Returns the value of attribute datatype.



5
6
7
# File 'app/components/oversee/field.rb', line 5

def datatype
  @datatype
end

#keyObject (readonly)

Returns the value of attribute key.



3
4
5
# File 'app/components/oversee/field.rb', line 3

def key
  @key
end

#resourceObject (readonly)

Returns the value of attribute resource.



2
3
4
# File 'app/components/oversee/field.rb', line 2

def resource
  @resource
end

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'app/components/oversee/field.rb', line 4

def value
  @value
end

Instance Method Details

#__FORM__Object



23
# File 'app/components/oversee/field.rb', line 23

def __FORM__ = Oversee::Field::Form.new(resource:, key:, value:, datatype:, **@options)

#__INPUT__Object



22
# File 'app/components/oversee/field.rb', line 22

def __INPUT__ = Oversee::Field::Input.new(resource:, key:, value:, datatype:, **@options)

#__LABEL__Object

Sub-components



20
# File 'app/components/oversee/field.rb', line 20

def __LABEL__ = Oversee::Field::Label.new(resource:, key:, value:, datatype:, **@options)

#__SET__Object



24
# File 'app/components/oversee/field.rb', line 24

def __SET__ = Oversee::Field::Set.new(resource:, key:, value:, datatype:, **@options)

#__VALUE__Object



21
# File 'app/components/oversee/field.rb', line 21

def __VALUE__ = Oversee::Field::Value.new(resource:, key:, value:, datatype:, **@options)

#field_form_idObject



35
36
37
# File 'app/components/oversee/field.rb', line 35

def field_form_id
  @form_id ||= dom_id(resource, "#{key}_form")
end

#field_idObject

Helpers & Decorators



27
28
29
# File 'app/components/oversee/field.rb', line 27

def field_id
  @field_id ||= "resource_#{key}"
end

#field_nameObject



31
32
33
# File 'app/components/oversee/field.rb', line 31

def field_name
  @field_name ||= "resource[#{key}]"
end

#resource_class_nameObject



39
40
41
# File 'app/components/oversee/field.rb', line 39

def resource_class_name
  @resource_class_name ||= @resource.class.name
end

#view_templateObject



15
16
17
# File 'app/components/oversee/field.rb', line 15

def view_template
  plain "Oversee::Field"
end