Class: Scheman::Schema::Table
- Inherits:
-
Object
- Object
- Scheman::Schema::Table
- Defined in:
- lib/scheman/schema.rb
Instance Method Summary collapse
- #fields ⇒ Array<Field>
- #fields_indexed_by_name ⇒ Hash{String => Field}
- #indices ⇒ Array<Hash>
-
#initialize(table) ⇒ Table
constructor
A new instance of Table.
- #name ⇒ String
Constructor Details
#initialize(table) ⇒ Table
Returns a new instance of Table.
36 37 38 |
# File 'lib/scheman/schema.rb', line 36 def initialize(table) @table = table end |
Instance Method Details
#fields ⇒ Array<Field>
46 47 48 49 50 |
# File 'lib/scheman/schema.rb', line 46 def fields @table[:fields].map do |field| Field.new(field[:field]) end end |
#fields_indexed_by_name ⇒ Hash{String => Field}
53 54 55 |
# File 'lib/scheman/schema.rb', line 53 def fields_indexed_by_name @fields_indexed_by_name ||= fields.index_by(&:name) end |
#indices ⇒ Array<Hash>
58 59 60 |
# File 'lib/scheman/schema.rb', line 58 def indices @indices ||= indices_from_definitions + indices_from_fields end |
#name ⇒ String
41 42 43 |
# File 'lib/scheman/schema.rb', line 41 def name @table[:name] end |