Class: PuzzlyApiPlugin::Context

Inherits:
Metadata show all
Defined in:
lib/puzzly_api_plugin/metadata/context.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, name, description) ⇒ Context

Returns a new instance of Context.



11
12
13
14
15
16
# File 'lib/puzzly_api_plugin/metadata/context.rb', line 11

def initialize(document, name, description)
  super(document, name)
  self[MetadataFields::DESCRIPTION] = description
  
  validate
end

Class Method Details

.create(document) ⇒ Object



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

def self.create(document)
  Context.new(document,
              document.data[YAMLFields::CONTEXT_NAME],
              document.data[YAMLFields::CONTEXT_DESCRIPTION])
end

Instance Method Details

#descriptionObject



28
29
30
# File 'lib/puzzly_api_plugin/metadata/context.rb', line 28

def description
  self[MetadataFields::DESCRIPTION]
end

#validateObject



18
19
20
21
22
23
24
25
26
# File 'lib/puzzly_api_plugin/metadata/context.rb', line 18

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

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