Sha256: 8813749ca35732df6b84dfe84a4d1e40816f1ddb0654080d301770765b3c0ab1

Contents?: true

Size: 1005 Bytes

Versions: 1

Compression:

Stored size: 1005 Bytes

Contents

module Manateq
  module Resource

    def self.included base
      base.extend ClassMethods
    end

    module ClassMethods
      def resource_name
        'resource'
      end

      def fill data
        nil
      end

      def compare resource, name
        false
      end

      def list
        data = Manateq::Helper.to_hash self.resource_name
        result = []
        data.each do |resource|
          r_obj = self.fill resource
          result.append(r_obj)
        end
        result
      end

      def search name
        data = self.list
        result = nil
        data.each do |resource|
          if self.compare resource, name
            result = resource
            break
          end
        end
        result
      end

      def get_by_id id
        data = self.list
        result = nil
        data.each do |resource|
          unless resource.id != id
            result = resource
            break
          end
        end
        result
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
manateq-0.1.0 lib/manateq/resource.rb