Sha256: f65c6f1f517469e3fd0399b5d27df2edea8818610ad446864811cc536b385976

Contents?: true

Size: 797 Bytes

Versions: 13

Compression:

Stored size: 797 Bytes

Contents

module ActionMixin
  extend ActiveSupport::Concern

  private

  def clear_actions
    @actions = []
  end

  def actions_present?
    @actions.present?
  end

  def fetch_actions(resource_hash)
    @actions = Array(resource_hash["actions"]).collect { |action| ManageIQ::API::Client::Action.new(action) }
  end

  def find_action(action)
    action_str = action.to_s
    @actions.detect { |a| a.name == action_str } if @actions
  end

  def action_defined?(action)
    find_action(action)
  end

  def actions=(action_array)
    @actions = action_array.blank? ? [] : action_array
  end

  def add_action(action)
    @actions << action
  end

  def action_result(hash)
    ManageIQ::API::Client::ActionResult.an_action_result?(hash) ? ManageIQ::API::Client::ActionResult.new(hash) : hash
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
manageiq-api-client-0.6.0 lib/manageiq/api/client/mixins/action_mixin.rb
manageiq-api-client-0.4.0 lib/manageiq/api/client/mixins/action_mixin.rb
manageiq-api-client-0.3.7 lib/manageiq/api/client/mixins/action_mixin.rb
manageiq-api-client-0.3.6 lib/manageiq/api/client/mixins/action_mixin.rb
manageiq-api-client-0.3.5 lib/manageiq/api/client/mixins/action_mixin.rb
manageiq-api-client-0.3.4 lib/manageiq/api/client/mixins/action_mixin.rb
manageiq-api-client-0.3.3 lib/manageiq/api/client/mixins/action_mixin.rb
manageiq-api-client-0.3.2 lib/manageiq/api/client/mixins/action_mixin.rb
manageiq-api-client-0.3.1 lib/manageiq/api/client/mixins/action_mixin.rb
manageiq-api-client-0.3.0 lib/manageiq/api/client/mixins/action_mixin.rb
manageiq-api-client-0.2.0 lib/manageiq/api/client/mixins/action_mixin.rb
manageiq-api-client-0.1.1 lib/manageiq/api/client/mixins/action_mixin.rb
manageiq-api-client-0.1.0 lib/manageiq/api/client/mixins/action_mixin.rb