Sha256: a165725573b588b0600901153329ff622a1a38bb1333c00a301ed01c59931616

Contents?: true

Size: 855 Bytes

Versions: 10

Compression:

Stored size: 855 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 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}"
    end

    private

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
nds_api-0.1.12 lib/nds_api/method.rb
nds_api-0.1.11 lib/nds_api/method.rb
nds_api-0.1.9 lib/nds_api/method.rb
nds_api-0.1.8 lib/nds_api/method.rb
nds_api-0.1.7 lib/nds_api/method.rb
nds_api-0.1.6 lib/nds_api/method.rb
nds_api-0.1.5 lib/nds_api/method.rb
nds_api-0.1.4 lib/nds_api/method.rb
nds_api-0.1.3 lib/nds_api/method.rb
nds_api-0.1.1 lib/nds_api/method.rb