Sha256: 0e074608db0802c66abeaa6875b1b45f1922ade7ad54c310ece75b36b78f9198

Contents?: true

Size: 982 Bytes

Versions: 5

Compression:

Stored size: 982 Bytes

Contents

require 'json'
require 'net/http'
require 'open-uri'
require 'uri'

module NdsApi
  class Method
    def initialize(method = '')
      @method = method.to_s
    end

    def is_create?
      @method.include? 'create'
    end

    def is_update?
      @method.include? 'update'
    end

    def is_search?
      @method.include? 'search'
    end

    def is_search_providers?
      @method.include? 'search_providers'
    end

    def action
      action = method_split[0]
      object_type =
        case method_split[1]
        when 'child'
          'children'
        when 'client'
          'clients'
        when 'referral'
          'referrals'
        when 'person'
          'persons'
        when 'provider'
          'providers'
        when 'providers'
          'providers'
        end
      "#{action}_#{object_type}#{method_split[2] ? "_#{method_split[2]}" : ''}"
    end

    private

    def method_split
      @method_split ||= @method.split('_')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nds_api-0.1.23 lib/nds_api/method.rb
nds_api-0.1.22 lib/nds_api/method.rb
nds_api-0.1.21 lib/nds_api/method.rb
nds_api-0.1.20 lib/nds_api/method.rb
nds_api-0.1.19 lib/nds_api/method.rb