Class: Headcount::Configuration::Base
- Inherits:
-
Object
- Object
- Headcount::Configuration::Base
- Defined in:
- lib/headcount/configuration.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #count(*arguments, &block) ⇒ Object
- #evaluate(&block) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
28 29 30 31 |
# File 'lib/headcount/configuration.rb', line 28 def initialize @path = 'db/headcount.json' @timestamp = '%Y-%m-%d %H:%M:%S' end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
26 27 28 |
# File 'lib/headcount/configuration.rb', line 26 def path @path end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
26 27 28 |
# File 'lib/headcount/configuration.rb', line 26 def @timestamp end |
Instance Method Details
#count(*arguments, &block) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/headcount/configuration.rb', line 37 def count(*arguments, &block) if list_given?(*arguments) count_each(arguments.flatten) else query = arguments[0] = arguments[1] || {} if query.respond_to?(:count) key = [:as] || Headcount::Support.key_for(query) # just ignore blocks for now # not really finding a need for nested declarations #if block_given? # evaluate(&block) #end Headcount.register(key, query) else raise UnsupportedQuery, 'query does not respond to :count' end end end |
#evaluate(&block) ⇒ Object
33 34 35 |
# File 'lib/headcount/configuration.rb', line 33 def evaluate(&block) instance_exec(self, &block) end |