Sha256: e985f974ecc5f897e9ad1e529658cab978c60b1c98691796f324c9b74e9eb3ec
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module Bidu module House class Report include JsonParser 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 def initialize(options) @json = DEFAULT_OPTION.merge(options) end def status @status ||= error? ? :error : :ok end def error? 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bidu-house-1.1.0 | lib/bidu/house/report.rb |