lib/bidu/house/report.rb in bidu-house-1.1.0 vs lib/bidu/house/report.rb in bidu-house-1.2.0
- old
+ new
@@ -1,20 +1,20 @@
module Bidu
module House
class Report
include JsonParser
+ require 'bidu/house/report/active_record'
require 'bidu/house/report/error'
require 'bidu/house/report/range'
ALLOWED_PARAMETERS = []
DEFAULT_OPTION = {}
attr_reader :json
- json_parse :period, type: :period
- json_parse :clazz, :base_scope, :id, case: :snake
+ json_parse :id, case: :snake
- def initialize(options)
+ def initialize(options = {})
@json = DEFAULT_OPTION.merge(options)
end
def status
@status ||= error? ? :error : :ok
@@ -24,29 +24,9 @@
raise 'Not implemented yet'
end
def as_json
{ status: status }
- end
-
- private
-
- def fetch_scoped(base, scope)
- if (scope.is_a?(Symbol))
- scope.to_s.split('.').inject(base) do |entries, method|
- entries.public_send(method)
- end
- else
- base.where(scope)
- end
- end
-
- def last_entries
- @last_entries ||= base.where('updated_at >= ?', period.seconds.ago)
- end
-
- def base
- fetch_scoped(clazz, base_scope)
end
end
end
end