Class: CommaParty::ParseBody

Inherits:
Object
  • Object
show all
Defined in:
lib/commaparty/parse_body.rb

Instance Method Summary collapse

Constructor Details

#initialize(element) ⇒ ParseBody

Returns a new instance of ParseBody.



4
5
6
# File 'lib/commaparty/parse_body.rb', line 4

def initialize(element)
  @element = element
end

Instance Method Details

#bodyObject



16
17
18
19
20
21
22
23
# File 'lib/commaparty/parse_body.rb', line 16

def body
  @body ||=
  if @element[1].is_a?(Hash)
    @element[2..-1]
  else
    @element[1..-1]
  end
end

#callObject



8
9
10
11
12
13
14
# File 'lib/commaparty/parse_body.rb', line 8

def call
  if nested?
    body.flatten(1)
  else
    body
  end
end

#nested?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/commaparty/parse_body.rb', line 25

def nested?
  body[0].is_a?(Array) && !body[0][0].is_a?(Symbol)
end