Class: DataShift::NodeContext
- Inherits:
-
Object
- Object
- DataShift::NodeContext
- Includes:
- Logging
- Defined in:
- lib/datashift/node_context.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#doc_context ⇒ Object
Returns the value of attribute doc_context.
-
#method_binding ⇒ Object
Returns the value of attribute method_binding.
-
#populator ⇒ Object
Returns the value of attribute populator.
-
#row_index ⇒ Object
Returns the value of attribute row_index.
Instance Method Summary collapse
- #contains_data? ⇒ Boolean
-
#initialize(doc_context, method_binding, row_idx, data) ⇒ NodeContext
constructor
A new instance of NodeContext.
- #next_update? ⇒ Boolean
- #process ⇒ Object
Methods included from Logging
#logdir, #logdir=, #logger, #verbose
Constructor Details
#initialize(doc_context, method_binding, row_idx, data) ⇒ NodeContext
Returns a new instance of NodeContext.
23 24 25 26 27 28 29 30 |
# File 'lib/datashift/node_context.rb', line 23 def initialize(doc_context, method_binding, row_idx, data) @doc_context = doc_context @method_binding = method_binding @row_index = row_idx @data = data @populator = PopulatorFactory.get_populator(method_binding) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
21 22 23 |
# File 'lib/datashift/node_context.rb', line 21 def data @data end |
#doc_context ⇒ Object
Returns the value of attribute doc_context.
17 18 19 |
# File 'lib/datashift/node_context.rb', line 17 def doc_context @doc_context end |
#method_binding ⇒ Object
Returns the value of attribute method_binding.
17 18 19 |
# File 'lib/datashift/node_context.rb', line 17 def method_binding @method_binding end |
#populator ⇒ Object
Returns the value of attribute populator.
19 20 21 |
# File 'lib/datashift/node_context.rb', line 19 def populator @populator end |
#row_index ⇒ Object
Returns the value of attribute row_index.
17 18 19 |
# File 'lib/datashift/node_context.rb', line 17 def row_index @row_index end |
Instance Method Details
#contains_data? ⇒ Boolean
34 35 36 |
# File 'lib/datashift/node_context.rb', line 34 def contains_data? !(data.nil? || data.to_s.empty?) end |
#next_update? ⇒ Boolean
38 39 40 41 42 43 |
# File 'lib/datashift/node_context.rb', line 38 def next_update? false # for now create only # TODO : Support UPDATES # next = ProcessingRules.next_action(method_binding ) # next == :update end |
#process ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/datashift/node_context.rb', line 45 def process populator.prepare_and_assign(self, doc_context.load_object, data) rescue StandardError => x failed = FailureData.new( doc_context.load_object, self, x.) failed. << "Failed to process node : #{method_binding.pp}" doc_context.progress_monitor.failure(failed) logger.error("#{x.backtrace.first} : #{x.}") raise x end |