Sha256: c34af31473f5cba7a21a7097765fdd9318433be6db68f319ac2a661f58abddf1

Contents?: true

Size: 1.99 KB

Versions: 9

Compression:

Stored size: 1.99 KB

Contents

module DomoscioRails
  module HTTPCalls

    module Create
      module ClassMethods
        def create(*id, params)
          id = id.empty? ? nil : id[0]
          DomoscioRails.request(:post, url(id, nil, params), params)
        end
      end

      def self.included(base)
        base.extend(ClassMethods)
      end
    end

    module Update
      module ClassMethods
        def update(id = nil, params = {})
          DomoscioRails.request(:put, url(id, nil, params), params)
        end
      end

      def self.included(base)
        base.extend(ClassMethods)
      end
    end

    module Fetch
      module ClassMethods
        def fetch(id = nil, params = {})
          DomoscioRails.request(:get, url(id, nil, params), params)
        end
      end

      def self.included(base)
        base.extend(ClassMethods)
      end
    end

    module Destroy
      module ClassMethods
        def destroy(id = nil, params = {})
          DomoscioRails.request(:delete, url(id, nil, params), params)
        end
      end

      def self.included(base)
        base.extend(ClassMethods)
      end
    end

    module Util
      module ClassMethods
        def util(id = nil, util_name = nil, params = {})
          DomoscioRails.request(:get, url(id, util_name, params), params)
        end

        def util_post(id = nil, util_name = nil, params = {})
          DomoscioRails.request(:post, url(id, util_name, params), params)
        end
      end

      def self.included(base)
        base.extend(ClassMethods)
      end
    end

    # Raw module allow calls not to be scoped by instance
    module Raw
      module ClassMethods
        def raw_util(util_name = nil, params = {})
          DomoscioRails.request(:get, raw_url(util_name), raw_params(params))
        end

        def raw_util_post(util_name = nil, params = {})
          DomoscioRails.request(:post, raw_url(util_name), raw_params(params))
        end
      end

      def self.included(base)
        base.extend(ClassMethods)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
domoscio_rails-0.4.33 lib/domoscio_rails/http_calls.rb
domoscio_rails-0.4.32 lib/domoscio_rails/http_calls.rb
domoscio_rails-0.4.31 lib/domoscio_rails/http_calls.rb
domoscio_rails-0.4.30 lib/domoscio_rails/http_calls.rb
domoscio_rails-0.4.29 lib/domoscio_rails/http_calls.rb
domoscio_rails-0.4.28 lib/domoscio_rails/http_calls.rb
domoscio_rails-0.4.27 lib/domoscio_rails/http_calls.rb
domoscio_rails-0.4.26 lib/domoscio_rails/http_calls.rb
domoscio_rails-0.4.25 lib/domoscio_rails/http_calls.rb