Sha256: 4ed3072d8f07843263e56a360d0d08584085b31893505573f6e5a08e7681314a

Contents?: true

Size: 987 Bytes

Versions: 1

Compression:

Stored size: 987 Bytes

Contents

module Zertico
  class Service
    module InstanceMethods
      def index
        instance_variable_set("@#{interface_name.pluralize}", resource_source.all)
      end

      def new
        instance_variable_set("@#{interface_name}", resource_source.new)
      end

      def show(params)
        instance_variable_set("@#{interface_name}", resource_source.find(params[interface_id.to_sym]))
      end

      def create(params)
        instance_variable_set("@#{interface_name}", resource_source.create(params))
      end

      def update(params)
        show(params)
        instance_variable_get("@#{interface_name}").update_attributes(params)
        instance_variable_get("@#{interface_name}")
      end

      def destroy(params)
        show(params)
        instance_variable_get("@#{interface_name}").destroy
        instance_variable_get("@#{interface_name}")
      end

      def resource_source
        self.class.resource_source || interface_class
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zertico-2.0.0.alpha.2 lib/zertico/service/instance_methods.rb