Sha256: 8c25fa83619a4bf71721a017cbd6a0e355cef3d5f690b128ff907bde32af32c0

Contents?: true

Size: 1.12 KB

Versions: 35

Compression:

Stored size: 1.12 KB

Contents

module SOULs
  class SOULsQuery < GraphQL::Schema::Resolver
    @schedule = nil
    class << self
      attr_accessor :schedule
    end

    def souls_post(url:, payload: {}, content_type: "application/json")
      response = Faraday.post(url, payload.to_json, "Content-Type": content_type)
      response.body
    end

    def souls_check_user_permissions(user, obj, method)
      raise(StandardError, "Invalid or Missing Token") unless user

      policy_class = obj.class.name + "Policy"
      policy_clazz = policy_class.constantize.new(user, obj)
      permission = policy_clazz.public_send(method)
      raise(Pundit::NotAuthorizedError, "permission error!") unless permission
    end

    def self.cron(schedule)
      self.schedule = schedule
    end

    def self.all_schedules
      schedule_list = {}
      Queries.constants.select { |c| Queries.const_get(c).is_a?(Class) }
             .each do |clname|
        next if clname == :BaseQuery

        job_schedule = Queries.const_get(clname).schedule
        schedule_list[clname] = job_schedule unless job_schedule.nil?
      end
      schedule_list
    end
  end
end

module Queries
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
souls-4.1.2 lib/souls/app/graphql/souls_query.rb
souls-4.1.1 lib/souls/app/graphql/souls_query.rb
souls-4.1.0 lib/souls/app/graphql/souls_query.rb
souls-4.0.3 lib/souls/app/graphql/souls_query.rb
souls-4.0.2 lib/souls/app/graphql/souls_query.rb
souls-4.0.1 lib/souls/app/graphql/souls_query.rb
souls-4.0.0 lib/souls/app/graphql/souls_query.rb
souls-3.0.8 lib/souls/app/graphql/souls_query.rb
souls-3.0.7 lib/souls/app/graphql/souls_query.rb
souls-3.0.6 lib/souls/app/graphql/souls_query.rb
souls-3.0.5 lib/souls/app/graphql/souls_query.rb
souls-3.0.4 lib/souls/app/graphql/souls_query.rb
souls-3.0.3 lib/souls/app/graphql/souls_query.rb
souls-3.0.2 lib/souls/app/graphql/souls_query.rb
souls-3.0.1 lib/souls/app/graphql/souls_query.rb
souls-3.0.0 lib/souls/app/graphql/souls_query.rb
souls-2.0.4 lib/souls/app/graphql/souls_query.rb
souls-2.0.3 lib/souls/app/graphql/souls_query.rb
souls-2.0.2 lib/souls/app/graphql/souls_query.rb
souls-2.0.1 lib/souls/app/graphql/souls_query.rb