Class: IWonder::Snapshot

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/i_wonder/snapshot.rb

Instance Method Summary collapse

Instance Method Details

#complex?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/models/i_wonder/snapshot.rb', line 28

def complex?
  self.complex_data.present?
end

#dataObject



24
25
26
# File 'app/models/i_wonder/snapshot.rb', line 24

def data
  self.count || self.complex_data
end

#data=(some_form_of_data) ⇒ Object



16
17
18
19
20
21
22
# File 'app/models/i_wonder/snapshot.rb', line 16

def data=(some_form_of_data)
  if some_form_of_data.is_a?(Hash)
    self.complex_data = some_form_of_data
  else
    self.count = some_form_of_data.to_i
  end
end

#has_some_dataObject



10
11
12
13
14
# File 'app/models/i_wonder/snapshot.rb', line 10

def has_some_data
  if count.blank? and complex_data.blank?
    errors.add(:base, "must have some data")
  end
end