Class: Netzke::FieldModel

Inherits:
Hash
  • Object
show all
Includes:
BasepackActiveRecord
Defined in:
lib/netzke/field_model.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all(params = {}) ⇒ Object



36
37
38
# File 'lib/netzke/field_model.rb', line 36

def self.all(params={})
  @@data
end

.column_namesObject

def self.data=(data)

@@raw_data = data
process_data

end



28
29
30
# File 'lib/netzke/field_model.rb', line 28

def self.column_names
  @@data.inject([]){|res, record| (res + record.keys).uniq}
end

.columnsObject



32
33
34
# File 'lib/netzke/field_model.rb', line 32

def self.columns
  column_names
end

.columns_hashObject



52
53
54
# File 'lib/netzke/field_model.rb', line 52

def self.columns_hash
  @@columns_hash
end

.count(params = {}) ⇒ Object



48
49
50
# File 'lib/netzke/field_model.rb', line 48

def self.count(params = {})
  @@data.size
end

.data_storage=(ds) ⇒ Object



18
19
20
21
# File 'lib/netzke/field_model.rb', line 18

def self.data_storage=(ds)
  @@storage = ds
  process_data
end

.find(id) ⇒ Object



44
45
46
# File 'lib/netzke/field_model.rb', line 44

def self.find(id)
  @@data[id-1]
end

.firstObject



40
41
42
# File 'lib/netzke/field_model.rb', line 40

def self.first
  @@data[0]
end

.new_from_hash(hsh) ⇒ Object



5
6
7
# File 'lib/netzke/field_model.rb', line 5

def self.new_from_hash(hsh)
  self.new.replace(hsh)
end

.reflect_on_all_associationsObject



56
57
58
# File 'lib/netzke/field_model.rb', line 56

def self.reflect_on_all_associations
  []
end

.widget_name=(w) ⇒ Object

def self.json=(str)

@@data = ActiveSupport::JSON.decode(str)
process_data

end



14
15
16
# File 'lib/netzke/field_model.rb', line 14

def self.widget_name=(w)
  @@widget_name = w
end

Instance Method Details

#errorsObject



65
66
67
# File 'lib/netzke/field_model.rb', line 65

def errors
  []
end

#idObject

instance methods



61
62
63
# File 'lib/netzke/field_model.rb', line 61

def id
  self[:id] || self["id"]
end

#saveObject



69
70
71
# File 'lib/netzke/field_model.rb', line 69

def save
  true
end