Class: Super::Display::SchemaTypes

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

Overview

This schema type is meant to be used for #index or #show actions to transform database fields into something that is human friendly.

“‘ class MembersController::Controls

# ...

def show_schema
  Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type|
    fields[:name] = type.dynamic { |name| name }
    fields[:rank] = type.dynamic { |rank| rank }
    fields[:position] = type.dynamic { |position| position }
    fields[:ship] = type.dynamic { |ship| "#{ship.name} (Ship ##{ship.id})" }
    fields[:created_at] = type.dynamic { |created_at| created_at.iso8601 }
    fields[:updated_at] = type.dynamic { |updated_at| updated_at.iso8601 }
  end
end

# ...

end “‘

Defined Under Namespace

Classes: Dynamic

Instance Method Summary collapse

Instance Method Details

#dynamic(&transform_block) ⇒ Object



35
36
37
# File 'lib/super/display/schema_types.rb', line 35

def dynamic(&transform_block)
  Dynamic.new(transform_block)
end