Class: Textus::Store::Validator
- Inherits:
-
Object
- Object
- Textus::Store::Validator
- Defined in:
- lib/textus/store/validator.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(store) ⇒ Validator
constructor
A new instance of Validator.
Constructor Details
#initialize(store) ⇒ Validator
Returns a new instance of Validator.
4 5 6 |
# File 'lib/textus/store/validator.rb', line 4 def initialize(store) @store = store end |
Instance Method Details
#call ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/textus/store/validator.rb', line 8 def call violations = [] @store.manifest.enumerate.each do |row| begin @store.get(row[:key]) rescue Textus::Error => e violations << { "key" => row[:key], "code" => e.code, "message" => e. } end end @store.manifest.enumerate.each do |row| mentry = row[:manifest_entry] next unless mentry.schema schema = @store.schema_for(mentry.schema) next unless schema env = begin @store.get(row[:key]) rescue StandardError next end last_writer = @store.audit_log.last_writer_for(row[:key]) next if last_writer.nil? env["_meta"].each_key do |field| owner = schema.maintained_by(field) next if owner.nil? next if last_writer == owner next if last_writer == "human" violations << { "key" => row[:key], "code" => "role_authority", "field" => field, "expected" => owner, "last_writer" => last_writer, } end end { "protocol" => PROTOCOL, "ok" => violations.empty?, "violations" => violations } end |