Class: ComponentDescriptors::ComponentModule

Inherits:
SimpleDelegator
  • Object
show all
Includes:
OptionsParser, Logging
Defined in:
lib/component_descriptors.rb

Overview

Describes the mapping between key sections and fields of one component module from a patient document. This is a wrapper class around the root descriptor intended to provide a uniform handle on any base component module.

Constant Summary

Constant Summary

Constants included from OptionsParser

OptionsParser::KNOWN_KEYS

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from Logging

fallback, fallback=, included, #logger, #logger_color

Methods included from OptionsParser

#parse_args

Constructor Details

- (ComponentModule) initialize(*args, &descriptors)

Returns a new instance of ComponentModule



1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
# File 'lib/component_descriptors.rb', line 1035

def initialize(*args, &descriptors)
  self.original_arguments = args
  key, locator, options = parse_args(args)
  self.repeats = options.delete(:repeats)
  self.logger = options[:logger]
  self.component_descriptors = descriptors
  # XXX make this safer then a private call into the DSL module...factory method?
  self.root_descriptor = ComponentDescriptors::DSL.create(repeats? ? :repeating_section : :section, key, locator, options, &descriptors)
  super(root_descriptor)
  self
end

Instance Attribute Details

- (Object) component_descriptors

Returns the value of attribute component_descriptors



1033
1034
1035
# File 'lib/component_descriptors.rb', line 1033

def component_descriptors
  @component_descriptors
end

- (Object) original_arguments

Returns the value of attribute original_arguments



1033
1034
1035
# File 'lib/component_descriptors.rb', line 1033

def original_arguments
  @original_arguments
end

- (Object) repeats

Returns the value of attribute repeats



1033
1034
1035
# File 'lib/component_descriptors.rb', line 1033

def repeats
  @repeats
end

- (Object) root_descriptor

Returns the value of attribute root_descriptor



1033
1034
1035
# File 'lib/component_descriptors.rb', line 1033

def root_descriptor
  @root_descriptor
end

Instance Method Details

- (Object) copy

Create an unattached copy of the ComponentModule



1060
1061
1062
# File 'lib/component_descriptors.rb', line 1060

def copy
  ComponentModule.new(*original_arguments, &component_descriptors)
end

- (Object) name



1047
1048
1049
# File 'lib/component_descriptors.rb', line 1047

def name
  root_descriptor.section_key
end

- (Boolean) repeats?

Returns:

  • (Boolean)


1051
1052
1053
# File 'lib/component_descriptors.rb', line 1051

def repeats?
  @repeats
end

- (Object) to_s



1055
1056
1057
# File 'lib/component_descriptors.rb', line 1055

def to_s
  root_descriptor.to_s
end