Class: Oversee::Field::Value

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

Direct Known Subclasses

BelongsTo, Boolean, Date, Datetime, Enum, Integer, Json, RichText, String, Text

Defined Under Namespace

Classes: BelongsTo, Boolean, Date, Datetime, Enum, Integer, Json, RichText, String, Text

Constant Summary collapse

MAP =
{
  string: Oversee::Field::Value::String,
  belongs_to: Oversee::Field::Value::BelongsTo,
  boolean: Oversee::Field::Value::Boolean,
  date: Oversee::Field::Value::Date,
  datetime: Oversee::Field::Value::Datetime,
  enum: Oversee::Field::Value::Enum,
  integer: Oversee::Field::Value::Integer,
  json: Oversee::Field::Value::Json,
  jsonb: Oversee::Field::Value::Json,
  rich_text: Oversee::Field::Value::RichText,
  text: Oversee::Field::Value::Text,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key: nil, value: nil, datatype: :string, **options) ⇒ Value

Returns a new instance of Value.



20
21
22
23
24
25
26
27
# File 'app/components/oversee/field/value.rb', line 20

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

  @class = @options[:class]
end

Instance Attribute Details

#datatypeObject (readonly)

Returns the value of attribute datatype.



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

def datatype
  @datatype
end

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



17
18
19
# File 'app/components/oversee/field/value.rb', line 17

def value
  @value
end

Instance Method Details

#view_templateObject



29
30
31
32
# File 'app/components/oversee/field/value.rb', line 29

def view_template
  return p(class: "text-gray-400 text-xs"){ "" } if value.nil?
  render component_class.new(key:, value:, **@options)
end