Sha256: 69dae88e149a65c5611bbd9e3584b079ad39a2f9f82a68682ab84aaaf133c3c5

Contents?: true

Size: 789 Bytes

Versions: 9

Compression:

Stored size: 789 Bytes

Contents

# encoding: utf-8

module BitBucket
  class API

    # Returns all API public methods for a given class.
    def self.inherited(klass)
      klass.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
        def self.actions
          self.new.api_methods_in(#{klass})
        end
        def actions
          api_methods_in(#{klass})
        end
      RUBY_EVAL
      super
    end

    def api_methods_in(klass)
      methods = []
      (klass.send(:instance_methods, false) - ['actions']).sort.each do |method|
        methods << method
      end
      klass.included_modules.each do |mod|
        if mod.to_s =~ /#{klass}/
          mod.instance_methods(false).each do |met|
            methods << met
          end
        end
      end
      methods
    end

  end # API
end # BitBucket

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
zz_bitbucket_rest_api-0.1.11 lib/bitbucket_rest_api/api/actions.rb
zz_bitbucket_rest_api-0.1.10 lib/bitbucket_rest_api/api/actions.rb
zz_bitbucket_rest_api-0.1.9 lib/bitbucket_rest_api/api/actions.rb
zz_bitbucket_rest_api-0.1.8 lib/bitbucket_rest_api/api/actions.rb
bitbucket_rest_api2-0.9.5 lib/bitbucket_rest_api/api/actions.rb
bitbucket_rest_api2-0.9.1 lib/bitbucket_rest_api/api/actions.rb
bitbucket_rest_api2-0.2.2 lib/bitbucket_rest_api/api/actions.rb
bitbucket_rest_api2-0.2.1 lib/bitbucket_rest_api/api/actions.rb
bitbucket_rest_api2-0.2.0 lib/bitbucket_rest_api/api/actions.rb