Module: Schemata::ClassMethods

Defined in:
lib/schemata/common/msgbase.rb

Instance Method Summary collapse

Instance Method Details

#aux_schemaObject



153
154
155
# File 'lib/schemata/common/msgbase.rb', line 153

def aux_schema
  return self::AUX_SCHEMA if defined?(self::AUX_SCHEMA)
end

#mockObject



140
141
142
143
144
145
146
147
# File 'lib/schemata/common/msgbase.rb', line 140

def mock
  mock = {}
  mock_values.keys.each do |k|
    value = mock_values[k]
    mock[k] = value.respond_to?("call") ? value.call : value
  end
  self.new(mock)
end

#mock_valuesObject



157
158
159
# File 'lib/schemata/common/msgbase.rb', line 157

def mock_values
  self::MOCK_VALUES
end

#previous_versionObject



166
167
168
169
170
171
# File 'lib/schemata/common/msgbase.rb', line 166

def previous_version
  _, component, msg_type, version = self.name.split("::")
  version = version[1..-1].to_i - 1
  Schemata::const_get(component)::const_get(msg_type)::
    const_get("V#{version}")
end

#schemaObject



149
150
151
# File 'lib/schemata/common/msgbase.rb', line 149

def schema
  self::SCHEMA
end

#versionObject



161
162
163
164
# File 'lib/schemata/common/msgbase.rb', line 161

def version
  _, component, msg_type, version = self.name.split("::")
  version[1..-1].to_i
end