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
- #computed(type = :column, &transform_block) ⇒ Object
-
#initialize(fields:) ⇒ SchemaTypes
constructor
A new instance of SchemaTypes.
- #manual(&transform_block) ⇒ Object
- #real(type = :column, &transform_block) ⇒ Object
- #rich_text ⇒ Object
- #string ⇒ Object (also: #text)
- #time ⇒ Object
- #timestamp ⇒ Object
Constructor Details
#initialize(fields:) ⇒ SchemaTypes
Returns a new instance of SchemaTypes.
64 65 66 67 |
# File 'lib/super/display/schema_types.rb', line 64 def initialize(fields:) @actions_called = false @fields = fields end |
Instance Method Details
#actions ⇒ Object
103 104 105 106 107 108 |
# File 'lib/super/display/schema_types.rb', line 103 def actions @actions_called = true Builder.new.computed.none.transform do Partial.new("display_actions") end end |
#actions_called? ⇒ Boolean
111 112 113 |
# File 'lib/super/display/schema_types.rb', line 111 def actions_called? @actions_called end |
#computed(type = :column, &transform_block) ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/super/display/schema_types.rb', line 78 def computed(type = :column, &transform_block) TYPES .case(type) .when(:column) { Builder.new.computed.ignore_nil.column.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
87 88 89 |
# File 'lib/super/display/schema_types.rb', line 87 def manual(&transform_block) real(:column, &transform_block) end |
#real(type = :column, &transform_block) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/super/display/schema_types.rb', line 69 def real(type = :column, &transform_block) TYPES .case(type) .when(:column) { Builder.new.real.ignore_nil.column.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
97 98 99 100 101 |
# File 'lib/super/display/schema_types.rb', line 97 def rich_text computed do |value| Partial.new("display_rich_text", locals: { rich_text: value }) end end |
#string ⇒ Object Also known as: text
91 |
# File 'lib/super/display/schema_types.rb', line 91 def string; real(&:to_s); end |
#time ⇒ Object
95 |
# File 'lib/super/display/schema_types.rb', line 95 def time; real { |value| value.strftime("%H:%M:%S") }; end |
#timestamp ⇒ Object
94 |
# File 'lib/super/display/schema_types.rb', line 94 def ; real(&:to_s); end |