Sha256: 227a8a4c98942764ea6f62103151606ca97b2974ea74b2f11db5f3481a6be9d2

Contents?: true

Size: 1.01 KB

Versions: 34

Compression:

Stored size: 1.01 KB

Contents

module Types
  class OverridenAnsibleVariable < ::Types::AnsibleVariable
    description 'Ansible Variable with an override value for a host'
    model_class ::AnsibleVariable

    field :current_value, ::Types::AnsibleVariableOverride, :null => true
    field :lookup_values, ::Types::LookupValue.connection_type do
      argument :match, String, required: false
    end

    field :meta, ::Types::Meta

    def meta
      {
        :can_edit => ::User.current.can?(object.ansible_variable.permission_name(:edit), object.ansible_variable),
        :can_destroy => ::User.current.can?(object.ansible_variable.permission_name(:destroy), object.ansible_variable)
      }
    end

    def lookup_values(match: nil)
      return CollectionLoader.for(object.ansible_variable.class, :lookup_values).load(object.ansible_variable) unless match

      scope = lambda do |sc|
        sc.where(:match => match)
      end
      CollectionLoader.for(object.ansible_variable.class, :lookup_values, scope).load(object.ansible_variable)
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
foreman_ansible-15.0.2 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-15.0.1 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-15.0.0 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-14.2.2 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-14.2.1 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-13.0.7 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-14.2.0 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-14.1.1 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-14.1.0 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-13.0.5 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-14.0.0 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-13.0.4 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-13.0.3 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-13.0.2 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-13.0.1 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-13.0.0 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-12.0.7 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-10.4.4 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-12.0.6 app/graphql/types/overriden_ansible_variable.rb
foreman_ansible-12.0.5 app/graphql/types/overriden_ansible_variable.rb