Class: Super::Form::SchemaTypes::Generic
- Inherits:
-
Object
- Object
- Super::Form::SchemaTypes::Generic
- Defined in:
- lib/super/form/schema_types.rb
Instance Attribute Summary collapse
-
#nested_fields ⇒ Object
readonly
Returns the value of attribute nested_fields.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](key) ⇒ Object
-
#initialize(partial_path:, extras:, nested:) ⇒ Generic
constructor
A new instance of Generic.
- #label ⇒ Object
- #reader ⇒ Object
-
#to_partial_path ⇒ String
This takes advantage of a feature of Rails.
Constructor Details
#initialize(partial_path:, extras:, nested:) ⇒ Generic
Returns a new instance of Generic.
26 27 28 29 30 |
# File 'lib/super/form/schema_types.rb', line 26 def initialize(partial_path:, extras:, nested:) @partial_path = partial_path @extras = extras @nested_fields = nested end |
Instance Attribute Details
#nested_fields ⇒ Object (readonly)
Returns the value of attribute nested_fields.
32 33 34 |
# File 'lib/super/form/schema_types.rb', line 32 def nested_fields @nested_fields end |
Instance Method Details
#==(other) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/super/form/schema_types.rb', line 62 def ==(other) return false if other.class != self.class return false if other.instance_variable_get(:@partial_path) != @partial_path return false if other.instance_variable_get(:@extras) != @extras return false if other.instance_variable_get(:@nested_fields) != @nested_fields true end |
#[](key) ⇒ Object
44 45 46 |
# File 'lib/super/form/schema_types.rb', line 44 def [](key) @extras[key] end |
#label ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/super/form/schema_types.rb', line 52 def label if @extras.key?(:label) return @extras[:label] end if @extras.key?(:reader) return @extras[:reader].to_s.singularize.humanize end end |
#reader ⇒ Object
48 49 50 |
# File 'lib/super/form/schema_types.rb', line 48 def reader @extras[:reader] end |
#to_partial_path ⇒ String
This takes advantage of a feature of Rails. If the value of ‘#to_partial_path` is `my_form_field`, Rails renders `app/views/super/application/_my_form_field.html.erb`, and this instance of Generic is accessible via `my_form_field`
40 41 42 |
# File 'lib/super/form/schema_types.rb', line 40 def to_partial_path @partial_path end |