Class: Super::Display::SchemaTypes
- Inherits:
-
Object
- Object
- Super::Display::SchemaTypes
- Defined in:
- lib/super/display/schema_types.rb
Defined Under Namespace
Constant Summary collapse
Instance Method Summary collapse
- #actions ⇒ Object
- #actions_called? ⇒ Boolean
- #batch ⇒ Object
- #computed(type = :attribute, &transform_block) ⇒ Object
-
#initialize(fields:) ⇒ SchemaTypes
constructor
A new instance of SchemaTypes.
- #manual(&transform_block) ⇒ Object
- #real(type = :attribute, &transform_block) ⇒ Object
- #rich_text ⇒ Object
- #string ⇒ Object
- #time ⇒ Object
- #timestamp ⇒ Object
Constructor Details
#initialize(fields:) ⇒ SchemaTypes
Returns a new instance of SchemaTypes.
85 86 87 88 |
# File 'lib/super/display/schema_types.rb', line 85 def initialize(fields:) @actions_called = false @fields = fields end |
Instance Method Details
#actions ⇒ Object
136 137 138 139 140 141 |
# File 'lib/super/display/schema_types.rb', line 136 def actions @actions_called = true Builder.new.computed.none.transform do Partial.new("display_actions") end end |
#actions_called? ⇒ Boolean
144 145 146 |
# File 'lib/super/display/schema_types.rb', line 144 def actions_called? @actions_called end |
#batch ⇒ Object
112 113 114 115 116 |
# File 'lib/super/display/schema_types.rb', line 112 def batch real do |value| Partial.new("batch_checkbox", locals: {value: value}) end end |
#computed(type = :attribute, &transform_block) ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/super/display/schema_types.rb', line 99 def computed(type = :attribute, &transform_block) TYPES .case(type) .when(:attribute) { Builder.new.computed.ignore_nil.attribute.transform(&transform_block) } .when(:record) { Builder.new.computed.ignore_nil.record.transform(&transform_block) } .when(:none) { Builder.new.computed.ignore_nil.none.transform(&transform_block) } .result end |
#manual(&transform_block) ⇒ Object
108 109 110 |
# File 'lib/super/display/schema_types.rb', line 108 def manual(&transform_block) real(:attribute, &transform_block) end |
#real(type = :attribute, &transform_block) ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/super/display/schema_types.rb', line 90 def real(type = :attribute, &transform_block) TYPES .case(type) .when(:attribute) { Builder.new.real.ignore_nil.attribute.transform(&transform_block) } .when(:record) { Builder.new.real.ignore_nil.record.transform(&transform_block) } .when(:none) { Builder.new.real.ignore_nil.none.transform(&transform_block) } .result end |
#rich_text ⇒ Object
130 131 132 133 134 |
# File 'lib/super/display/schema_types.rb', line 130 def rich_text computed do |value| Partial.new("display_rich_text", locals: {rich_text: value}) end end |
#string ⇒ Object
118 119 120 |
# File 'lib/super/display/schema_types.rb', line 118 def string real(&:to_s) end |
#time ⇒ Object
126 127 128 |
# File 'lib/super/display/schema_types.rb', line 126 def time real { |value| value.strftime("%H:%M:%S") } end |
#timestamp ⇒ Object
122 123 124 |
# File 'lib/super/display/schema_types.rb', line 122 def real(&:to_s) end |