Sha256: c6a3f8a0608d7573bb892ca325195ec8f993b8e1d7a8d9dfaa3a82a18c9fe1c0

Contents?: true

Size: 837 Bytes

Versions: 1

Compression:

Stored size: 837 Bytes

Contents

module Trole
  module Api
    #
    # When the Trole::Api is included by the Role Subject class (fx a User Account)
    # first include methods from Troles Common API      
    # then include Trole API on top
    #
    # @param [Class] the role subject class (fx User or UserAccount)
    #
    module ClassMethods
      def included(base)
        base.send :include, Troles::Common::Api
        self.extend Troles::Common::Api::ClassMethods # draws in the #apis method from Common Api

        apis.each do |api|
          begin
            base.send :include, "Trole::Api::#{api.to_s.camelize}".constantize
            base.extend "Trole::Api::#{api.to_s.camelize}::ClassMethods".constantize            
            # base.include_and_extend :"#{api.to_s.camelize}"
          rescue
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
troles-0.6.1 lib/trole/api/class_methods.rb