class HID::Persistence::ActiveRecord::Recorder
Attributes
records_class[RW]
Public Class Methods
record(input, type)
click to toggle source
# File lib/hid/persistence/active_record/recorder.rb, line 11 def record(input, type) records_class.create input: input, id_type: type nil end
recorded(type)
click to toggle source
# File lib/hid/persistence/active_record/recorder.rb, line 16 def recorded(type) return typed_records(type) if type untyped_records end
Private Class Methods
typed_records(type)
click to toggle source
# File lib/hid/persistence/active_record/recorder.rb, line 23 def typed_records(type) records_class.where(id_type: type).pluck(:input) end
untyped_records()
click to toggle source
# File lib/hid/persistence/active_record/recorder.rb, line 27 def untyped_records record_groups = records_class.all.group_by(&:id_type) hash = Hash.new record_groups.each do |type, records| hash[type] = records.map(&:input) if records end hash end