Sha256: 682668d94b8e60655b52ba58e9900d611d4e4107de5d3419a11d0b1d6bfc5fc3

Contents?: true

Size: 911 Bytes

Versions: 5

Compression:

Stored size: 911 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}#{method_split[2].present? ? "_#{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.18 lib/nds_api/method.rb
nds_api-0.1.17 lib/nds_api/method.rb
nds_api-0.1.16 lib/nds_api/method.rb
nds_api-0.1.15 lib/nds_api/method.rb
nds_api-0.1.14 lib/nds_api/method.rb