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.



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

def initialize(fields:)
  @fields = fields
end

Instance Method Details

#_destroy(**extras) ⇒ Object



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

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

#checkbox(**extras) ⇒ Object



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

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

#generic(partial_path, **extras) ⇒ Object



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

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

#has_many(reader, **extras) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/super/form/schema_types.rb', line 89

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



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

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



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

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

#select(**extras) ⇒ Object



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

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

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



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

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