Class: Mumukit::Service::DocumentArray

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/mumukit/service/document_array.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw, options = {}) ⇒ DocumentArray

Returns a new instance of DocumentArray.



8
9
10
11
# File 'lib/mumukit/service/document_array.rb', line 8

def initialize(raw, options={})
  @raw = raw
  @default_key = options[:default_key]
end

Instance Attribute Details

#rawObject

Returns the value of attribute raw.



4
5
6
# File 'lib/mumukit/service/document_array.rb', line 4

def raw
  @raw
end

Instance Method Details

#array_keyObject



19
20
21
# File 'lib/mumukit/service/document_array.rb', line 19

def array_key
  @default_key || key
end

#as_json(options = {}) ⇒ Object



13
14
15
16
17
# File 'lib/mumukit/service/document_array.rb', line 13

def as_json(options={})
  {}.tap do |json|
    json[array_key] = raw.as_json(self.options.merge(options))
  end
end

#optionsObject



23
24
25
# File 'lib/mumukit/service/document_array.rb', line 23

def options
  {}
end