Sha256: 90d2075b6c112a7a61074bb23a34b7330066873833a57688decab3ed0dc29a2e

Contents?: true

Size: 867 Bytes

Versions: 6

Compression:

Stored size: 867 Bytes

Contents

class Mite::TimeEntryGroup < Mite::Base
  self.collection_name = "time_entries"

  attr_accessor :time_entries_params

  class << self
    def find_every(options={})
      return Mite::TimeEntry.all(options) if !options[:params] || !options[:params][:group_by]

      super(options).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

  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

    Mite::TimeEntry.all(options)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mite-rb-0.5.4 lib/mite/time_entry_group.rb
mite-rb-0.5.3 lib/mite/time_entry_group.rb
mite-rb-0.5.2 lib/mite/time_entry_group.rb
mite-rb-0.5.1 lib/mite/time_entry_group.rb
mite-rb-0.5.0 lib/mite/time_entry_group.rb
mite-rb-0.4.5 lib/mite/time_entry_group.rb