Class: PuzzlyApiPlugin::Table

Inherits:
Metadata show all
Defined in:
lib/puzzly_api_plugin/metadata/table.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Metadata

#id, #name, #path, #to_identity

Methods inherited from JSONable

#copy_to_hash, #to_s

Constructor Details

#initialize(document, module_id, name, description, schema_file) ⇒ Table

Returns a new instance of Table.



13
14
15
16
17
18
19
20
# File 'lib/puzzly_api_plugin/metadata/table.rb', line 13

def initialize(document, module_id, name, description, schema_file)
  super(document, name)
  self[MetadataFields::MODULE_ID] = module_id
  self[MetadataFields::DESCRIPTION] = description
  self[MetadataFields::SCHEMA_FILE] = schema_file

  validate
end

Class Method Details

.create(document) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/puzzly_api_plugin/metadata/table.rb', line 5

def self.create(document)
  Table.new(document,
            document.data[YAMLFields::MODULE_ID],
            document.data[YAMLFields::TABLE_NAME],
            document.data[YAMLFields::TABLE_DESCRIPTION],
            document.data[YAMLFields::TABLE_SCHEMA_FILE])
end

Instance Method Details

#descriptionObject



44
45
46
# File 'lib/puzzly_api_plugin/metadata/table.rb', line 44

def description
  self[MetadataFields::DESCRIPTION]
end

#module_idObject



40
41
42
# File 'lib/puzzly_api_plugin/metadata/table.rb', line 40

def module_id
  self[MetadataFields::MODULE_ID]
end

#schema_fileObject



48
49
50
# File 'lib/puzzly_api_plugin/metadata/table.rb', line 48

def schema_file
  self[MetadataFields::SCHEMA_FILE]
end

#validateObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/puzzly_api_plugin/metadata/table.rb', line 22

def validate     
  if(module_id.nil?)
    warn "Please set #{YAMLFields::MODULE_ID} property"
  end

  if(name.nil?)
    warn "Please set #{YAMLFields::TABLE_NAME} property"
  end

  if(description.nil?)
    warn "Please set #{YAMLFields::TABLE_DESCRIPTION} property"
  end

  if(schema_file.nil?)
    warn "Please set #{YAMLFields::TABLE_SCHEMA_FILE} property"
  end
end