Sha256: b73d50031132417889918927057660a3653bdb9093af0d3afbfbf5586937529d

Contents?: true

Size: 1.37 KB

Versions: 8

Compression:

Stored size: 1.37 KB

Contents

require "active_support"
require "restly/version"
require "oauth2"

module Restly
  extend ActiveSupport::Autoload

  autoload :Base
  autoload :BaseProxy
  autoload :Proxies
  autoload :Configuration
  autoload :Collection
  autoload :ControllerMethods
  autoload :Associations
  autoload :EmbeddedAssociations
  autoload :NestedAttributes
  autoload :Error
  autoload :Connection
  autoload :Middleware
  autoload :ThreadLocal
  autoload :Client
  autoload :ConcernedInheritance

  if defined?(Rails::Console)
    def self.login(username, password, scope = "full")
      Base.current_token = { access_token: Client.new.password.get_token(username, password, scope: scope).token }
    end
  end

end

require 'restly/railtie' if Object.const_defined?('Rails')
require 'restly/notifications'

class Object

  @@__method_calls ||= {}

  def current_method(index=0)
    /`(?<curr_method>.*?)'/ =~ caller[index]
    curr_method
  end

  def method_called(enum, *args)
    count = enum.count
    method = Digest::MD5.hexdigest( current_method(1) + args.to_sentence )

    @@__method_calls.delete_if { |k, v| v[:timestamp] < Time.now - 10 }
    @@__method_calls[method.to_sym] ||= {}
    @@__method_calls[method.to_sym][:count] ||= 0
    @@__method_calls[method.to_sym][:count] += 1
    @@__method_calls[method.to_sym][:timestamp] = Time.now

    @@__method_calls[method.to_sym][:count] >= count
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
restly-0.0.1.beta.10 lib/restly.rb
restly-0.0.1.beta.9 lib/restly.rb
restly-0.0.1.beta.6 lib/restly.rb
restly-0.0.1.beta.5 lib/restly.rb
restly-0.0.1.beta.4 lib/restly.rb
restly-0.0.1.beta.3 lib/restly.rb
restly-0.0.1.beta.2 lib/restly.rb
restly-0.0.1.beta.1 lib/restly.rb