Class: SyoboiCalendar::Queries::BaseQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/syoboi_calendar/queries/base_query.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ BaseQuery


26
27
28
# File 'lib/syoboi_calendar/queries/base_query.rb', line 26

def initialize(options = {})
  @options = options
end

Class Attribute Details

.property_namesArray<Symbol>


13
14
15
# File 'lib/syoboi_calendar/queries/base_query.rb', line 13

def property_names
  @property_names ||= []
end

Class Method Details

.inherited(child_class) ⇒ Object

Note:

Override


8
9
10
# File 'lib/syoboi_calendar/queries/base_query.rb', line 8

def inherited(child_class)
  child_class.property_names = property_names.clone
end

.property(property_name) ⇒ Object


18
19
20
# File 'lib/syoboi_calendar/queries/base_query.rb', line 18

def property(property_name)
  property_names << property_name
end

Instance Method Details

#CommandString

Raises:

  • (::NotImplementedError)

31
32
33
# File 'lib/syoboi_calendar/queries/base_query.rb', line 31

def Command
  raise ::NotImplementedError
end

#LastUpdateString?


36
37
38
# File 'lib/syoboi_calendar/queries/base_query.rb', line 36

def LastUpdate
  format_time_range(options[:updated_from], options[:updated_to])
end

#to_hashHash


41
42
43
44
45
46
47
48
# File 'lib/syoboi_calendar/queries/base_query.rb', line 41

def to_hash
  self.class.property_names.each_with_object({}) do |property_name, result|
    value = send(property_name)
    unless value.nil?
      result[property_name.to_s] = value
    end
  end
end