Class: NfsePrefeituraSp::Types::Complex
- Inherits:
-
Object
- Object
- NfsePrefeituraSp::Types::Complex
show all
- Defined in:
- lib/nfse_prefeitura_sp/types/complex.rb
Instance Method Summary
collapse
Constructor Details
#initialize(key, data, signer = nil) ⇒ Complex
Returns a new instance of Complex.
3
4
5
6
7
8
9
10
11
12
|
# File 'lib/nfse_prefeitura_sp/types/complex.rb', line 3
def initialize(key, data, signer = nil)
@key = key
@data = data || {}
@data = (@data.respond_to?('with_indifferent_access') ? @data.with_indifferent_access : @data)
@signer = signer
@children = {}
initialize_children
@children.each { |key, child| define_singleton_method(key) { child } }
end
|
Instance Method Details
28
29
30
|
# File 'lib/nfse_prefeitura_sp/types/complex.rb', line 28
def add_children_tags_to_xml
raise "[NfsePrefeituraSp] Method not implemented error."
end
|
#add_tag_to_xml(xml, attrs = {}) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/nfse_prefeitura_sp/types/complex.rb', line 20
def add_tag_to_xml(xml, attrs = {})
if has_any_child_value?
xml.send(@key, attrs) do
add_children_tags_to_xml(xml)
end
end
end
|
#has_any_child_value? ⇒ Boolean
16
17
18
|
# File 'lib/nfse_prefeitura_sp/types/complex.rb', line 16
def has_any_child_value?
@children.find { |_, child| child.has_any_child_value? }
end
|
#initialize_children ⇒ Object
14
|
# File 'lib/nfse_prefeitura_sp/types/complex.rb', line 14
def initialize_children; end
|