class ReportLogic::Base

Attributes

collection[R]

Public Class Methods

collection_session(key, &block) click to toggle source
# File lib/report_logic/base.rb, line 31
def self.collection_session(key, &block)
  define_method key do
    collection_fields &block
  end
end
new(collection = nil) click to toggle source
# File lib/report_logic/base.rb, line 5
def initialize(collection = nil)
  @collection = collection
end
session(key, &block) click to toggle source
# File lib/report_logic/base.rb, line 23
def self.session(key, &block)
  define_method key do
    @current = []
    instance_eval &block
    @current
  end
end

Public Instance Methods

collection_fields(&block) click to toggle source
# File lib/report_logic/base.rb, line 15
def collection_fields(&block)
  collection.map do |record|
    fields do
      instance_exec record, &block
    end
  end
end
count() click to toggle source
# File lib/report_logic/base.rb, line 47
def count
  collection.size
end
each(key) click to toggle source
# File lib/report_logic/base.rb, line 37
def each(key)
  fail '`each` is not used anymore. Please, refer to the project\'s '\
       ' documentation on Github for more details.'
end
field(name, value = nil, **options) click to toggle source
# File lib/report_logic/base.rb, line 51
def field(name, value = nil, **options)
  @current << Field.new(name, value, **options)
end
fields(&block) click to toggle source
# File lib/report_logic/base.rb, line 9
def fields(&block)
  @current = []
  instance_exec &block
  @current
end
session(key, collection = nil, &block) click to toggle source
# File lib/report_logic/base.rb, line 42
def session(key, collection = nil, &block)
  fail '`session` is not used anymore. Please, refer to the project\'s '\
       ' documentation on Github for more details.'
end
value(val, **options) click to toggle source
# File lib/report_logic/base.rb, line 55
def value(val, **options)
  field(nil, val, **options)
end