Sha256: ffe3627c71cbab813f22b69cff54772d312b32317f51d775505e10ef7310dd19

Contents?: true

Size: 941 Bytes

Versions: 12

Compression:

Stored size: 941 Bytes

Contents

class Mite::TimeEntryGroup < Mite::Base
  self.collection_name = "time_entries"
  
  attr_accessor :time_entries_params
  
  class << self
    def find_every(options={})
      return TimeEntry.all(options) if !options[:params] || !options[:params][:group_by]
      
      returning super(options) do |records|
        records.each do |record| 
          if record.attributes["time_entries_params"]
            record.time_entries_params = record.attributes.delete("time_entries_params").attributes.stringify_keys
          end
        end
      end
    end
  end
  
  def time_entries(options={})
    return [] unless time_entries_params.is_a?(Hash)
    
    empty_result = false
    
    options[:params] ||= {}
    options[:params].stringify_keys!
    options[:params].merge!(time_entries_params) do |key, v1, v2|
      empty_result = (v1 != v2)
      v2
    end
    
    return [] if empty_result
    
    TimeEntry.all(options)
  end
end

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
Overbryd-mighty-mite-0.1.0 vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry_group.rb
Overbryd-mighty-mite-0.1.1 vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry_group.rb
Overbryd-mighty-mite-0.1.2 vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry_group.rb
Overbryd-mighty-mite-0.1.3 vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry_group.rb
Overbryd-mite.cmd-0.1.3 vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry_group.rb
Overbryd-mite.cmd-0.1.4 vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry_group.rb
Overbryd-mite.cmd-0.1.5 vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry_group.rb
Overbryd-mite.cmd-0.1.7 vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry_group.rb
Overbryd-mite.cmd-0.1.9 vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry_group.rb
yolk-mite-rb-0.0.2 lib/mite/time_entry_group.rb
yolk-mite-rb-0.0.3 lib/mite/time_entry_group.rb
mite.cmd-0.1.10 vendor/yolk-mite-rb-0.0.3/lib/mite/time_entry_group.rb