Sha256: e4adbb7c771d477e63c69a321abbf1be8302ce57e6b1d56bd2245134c41b6c61

Contents?: true

Size: 740 Bytes

Versions: 2

Compression:

Stored size: 740 Bytes

Contents

# coding: utf-8
require 'aepic'

module Aepic
  class Schema
    METHODS = {
      :index => :get,
      :show => :get,
      :update => [:put, :patch],
      :create => :post,
      :destroy => :delete,
      :edit => :get,
    }

    def self.default
      @default ||= new
    end

    def resources
      @resources ||=
        controllers.inject do |resources, controller|
          if controller.action_methods.include?('index')
            resources << Resource.new()
          end
          resources
        end
    end

    def controllers
      @controllers ||= Set.new
    end

    def <<(controller)
      controllers << controller
    end

    def method_for(action)
      METHODS[action.to_sym].to_s.upcase
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aepic-0.0.4 lib/aepic/schema.rb
aepic-0.0.2 lib/aepic/schema.rb