Sha256: 9fea4c2f387ce909a950fa3c2b49f683de6470398013c7b60494e292705e6770

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

# frozen_string_literal: true
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|
        next unless mod.to_s =~ /#{klass}/

        mod.instance_methods(false).each do |met|
          methods << met
        end
      end
      methods
    end
  end # API
end # BitBucket

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bitbuckets-0.2.0 lib/bitbucket_rest_api/api/actions.rb