Class: NcsNavigator::Warehouse::TransformError

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/ncs_navigator/warehouse/transform_status.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_exception(exception, context_message = nil) ⇒ Object



68
69
70
71
72
73
74
75
# File 'lib/ncs_navigator/warehouse/transform_status.rb', line 68

def self.for_exception(exception, context_message=nil)
  TransformError.new(:message => [
      context_message,
      "#{exception.class}: #{exception}",
      StringifyTrace.stringify_trace(exception.backtrace)
    ].compact.join("\n")
  )
end

Instance Method Details

#as_jsonHash

Provides fpr a JSON serialization that is compatible with SubprocessTransformer.

Returns:

  • (Hash)

    a key-value object containing just the serializable components of this instance



83
84
85
86
87
88
89
90
91
# File 'lib/ncs_navigator/warehouse/transform_status.rb', line 83

def as_json
  model.properties.
    reject { |p| [:id, :transform_status_id].include?(p.name) }.
    inject({}) { |json, prop|
      value = self.send(prop.name)
      json[prop.name.to_s] = value if value
      json
    }
end

#model_class=(clz) ⇒ Object



99
100
101
102
103
104
105
106
107
# File 'lib/ncs_navigator/warehouse/transform_status.rb', line 99

def model_class=(clz)
  super

  if clz.nil?
    self.table_name = nil
  elsif clz.respond_to?(:mdes_table_name)
    self.table_name = clz.mdes_table_name
  end
end

#to_jsonString

Returns single-line JSON serialization of #as_json.

Returns:

  • (String)

    single-line JSON serialization of #as_json.



95
96
97
# File 'lib/ncs_navigator/warehouse/transform_status.rb', line 95

def to_json
  as_json.to_json
end