Module: RestrictionCalculator::ClassMethods

Defined in:
backend/app/model/mixins/restriction_calculator.rb

Instance Method Summary collapse

Instance Method Details

#sequel_to_jsonmodel(objs, opts = {}) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'backend/app/model/mixins/restriction_calculator.rb', line 49

def sequel_to_jsonmodel(objs, opts = {})
  jsons = super

  unless opts[:skip_restrictions]
    jsons.zip(objs).each do |json, obj|
      json['active_restrictions'] = obj.active_restrictions.map {|restriction|
        RightsRestriction.to_jsonmodel(restriction)
      }
      json['restricted'] = !json['active_restrictions'].empty?
    end
  end

  jsons
end