Sha256: 64578918b98a3b58cc292ef30bee35189cd2bd2e79bbd4a4929f679502ccc67d

Contents?: true

Size: 1.5 KB

Versions: 6

Compression:

Stored size: 1.5 KB

Contents

#
# Copyright 2013-2017 Conjur Inc
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

module Conjur
  module Cast
    protected

    # Convert a value to a role or resource identifier.
    #
    # @param obj the value to cast
    def cast_to_id obj
      result =if obj.is_a?(String) || obj.is_a?(Id)
        obj
      elsif obj.is_a?(Array)
        obj.join(':')
      else
        raise "I don't know how to cast a #{obj.class} to an id"
      end
      result = Id.new(result) unless result.is_a?(Id)
      result
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
conjur-api-5.3.0 lib/conjur/cast.rb
conjur-api-5.2.1 lib/conjur/cast.rb
conjur-api-5.2.0 lib/conjur/cast.rb
conjur-api-5.1.0 lib/conjur/cast.rb
conjur-api-5.0.0 lib/conjur/cast.rb
conjur-api-5.0.0.rc1 lib/conjur/cast.rb