Module: Limited

Defined in:
lib/limited.rb,
lib/limited/actor.rb,
lib/limited/action.rb,
lib/limited/config.rb,
lib/limited/version.rb,
lib/limited/interval.rb

Defined Under Namespace

Modules: Config Classes: Action, Actor, Interval

Constant Summary collapse

VERSION =
"0.2.1"

Class Method Summary collapse

Class Method Details

.actionsObject

returns a hash containing all the limited actions



15
16
17
# File 'lib/limited.rb', line 15

def self.actions
  @actions
end

.configure(&block) ⇒ Object

executes a block inside Limited::Config so you can easily access the methods in it and configure the Limited gem

Example

Limited.configure do
  action :sending_contact_email, 50
  action :failed_login, 1337
end


48
49
50
# File 'lib/limited/config.rb', line 48

def self.configure(&block)
  Config.instance_eval &block
end

.identifiersObject



21
22
23
# File 'lib/limited.rb', line 21

def self.identifiers
  @identifiers
end

.method_missing(method_id, *arguments) ⇒ Object

:call-seq:

Limited.<action_name> -> Limited::Action

adds the possibility to access every action directly via Limited.<actionanem>

Example

Limited.configure do
  action :some_action, 123
end

Limited.some_action.executed
Limited.some_action.num_left # -> 122


41
42
43
44
45
46
47
# File 'lib/limited.rb', line 41

def self.method_missing(method_id, *arguments)
  if @actions.has_key?(method_id)
    @actions[method_id]
  else
    super
  end
end