Sha256: 845cac17c1ffc96ef35bc3656aac3218165b898143b6e875822d565849e47567

Contents?: true

Size: 851 Bytes

Versions: 13

Compression:

Stored size: 851 Bytes

Contents

module ManageIQ
  module API
    class Client
      class ActionResult
        attr_reader :attributes

        def initialize(action_hash)
          raise "Not a valid Action Result specified" unless self.class.an_action_result?(action_hash)
          @attributes = action_hash.dup
        end

        def self.an_action_result?(hash)
          hash && hash.key?("success") && hash.key?("message")
        end

        def succeeded?
          success
        end

        def failed?
          !success
        end

        def method_missing(sym, *args, &block)
          attributes && attributes.key?(sym.to_s) ? attributes[sym.to_s] : super(sym, *args, &block)
        end

        def respond_to_missing?(sym, *args, &block)
          attributes && attributes.key?(sym.to_s) || super(sym, *args, &block)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

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