Class: Super::Form::SchemaTypes

Inherits:
Object
  • Object
show all
Defined in:
lib/super/form/schema_types.rb

Defined Under Namespace

Classes: Generic

Instance Method Summary collapse

Constructor Details

#initialize(fields:) ⇒ SchemaTypes

Returns a new instance of SchemaTypes.



64
65
66
# File 'lib/super/form/schema_types.rb', line 64

def initialize(fields:)
  @fields = fields
end

Instance Method Details

#_destroy(**extras) ⇒ Object



128
129
130
131
132
133
134
# File 'lib/super/form/schema_types.rb', line 128

def _destroy(**extras)
  Generic.new(
    partial_path: "form_field__destroy",
    extras: extras,
    nested: {}
  )
end

#checkbox(**extras) ⇒ Object



86
87
88
# File 'lib/super/form/schema_types.rb', line 86

def checkbox(**extras)
  Generic.new(partial_path: "form_field_checkbox", extras: extras, nested: {})
end

#flatpickr_date(**extras) ⇒ Object



90
91
92
# File 'lib/super/form/schema_types.rb', line 90

def flatpickr_date(**extras)
  Generic.new(partial_path: "form_field_flatpickr_date", extras: extras, nested: {})
end

#flatpickr_datetime(**extras) ⇒ Object



94
95
96
# File 'lib/super/form/schema_types.rb', line 94

def flatpickr_datetime(**extras)
  Generic.new(partial_path: "form_field_flatpickr_datetime", extras: extras, nested: {})
end

#flatpickr_time(**extras) ⇒ Object



98
99
100
# File 'lib/super/form/schema_types.rb', line 98

def flatpickr_time(**extras)
  Generic.new(partial_path: "form_field_flatpickr_time", extras: extras, nested: {})
end

#generic(partial_path, **extras) ⇒ Object



68
69
70
# File 'lib/super/form/schema_types.rb', line 68

def generic(partial_path, **extras)
  Generic.new(partial_path: partial_path, extras: extras, nested: {})
end

#has_many(reader, **extras) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
# File 'lib/super/form/schema_types.rb', line 102

def has_many(reader, **extras)
  nested = @fields.nested do
    yield
  end

  Generic.new(
    partial_path: "form_has_many",
    extras: extras.merge(reader: reader),
    nested: nested
  )
end

#has_one(reader, **extras) ⇒ Object Also known as: belongs_to



114
115
116
117
118
119
120
121
122
123
124
# File 'lib/super/form/schema_types.rb', line 114

def has_one(reader, **extras)
  nested = @fields.nested do
    yield
  end

  Generic.new(
    partial_path: "form_has_one",
    extras: extras.merge(reader: reader),
    nested: nested
  )
end

#rich_text_area(**extras) ⇒ Object



82
83
84
# File 'lib/super/form/schema_types.rb', line 82

def rich_text_area(**extras)
  Generic.new(partial_path: "form_field_rich_text_area", extras: extras, nested: {})
end

#select(**extras) ⇒ Object



72
73
74
# File 'lib/super/form/schema_types.rb', line 72

def select(**extras)
  Generic.new(partial_path: "form_field_select", extras: extras, nested: {})
end

#string(**extras) ⇒ Object Also known as: text



76
77
78
# File 'lib/super/form/schema_types.rb', line 76

def string(**extras)
  Generic.new(partial_path: "form_field_text", extras: extras, nested: {})
end