Module: Exportable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Issuable
- Defined in:
- app/models/concerns/exportable.rb
Instance Method Summary collapse
- #exportable_association?(association, current_user: nil) ⇒ Boolean
- #restricted_associations(keys) ⇒ Object
- #to_authorized_json(keys_to_authorize, current_user, options) ⇒ Object
Instance Method Details
#exportable_association?(association, current_user: nil) ⇒ Boolean
6 7 8 9 10 11 12 13 14 |
# File 'app/models/concerns/exportable.rb', line 6 def exportable_association?(association, current_user: nil) return false unless respond_to?(association) return true if has_many_association?(association) readable = try(association) return true if readable.nil? readable_record?(readable, current_user) end |
#restricted_associations(keys) ⇒ Object
16 17 18 |
# File 'app/models/concerns/exportable.rb', line 16 def restricted_associations(keys) exportable_restricted_associations & keys end |
#to_authorized_json(keys_to_authorize, current_user, options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/concerns/exportable.rb', line 20 def (, current_user, ) = filtered_associations_opts(, ) record_hash = as_json().with_indifferent_access .each do |key| next unless record_hash.key?(key) record_hash[key] = (key, current_user, ) end record_hash.to_json end |