Class: Netzke::FieldModel
- Inherits:
-
Hash
- Object
- Hash
- Netzke::FieldModel
- Includes:
- BasepackActiveRecord
- Defined in:
- lib/netzke/field_model.rb
Class Method Summary collapse
- .all(params = {}) ⇒ Object
-
.column_names ⇒ Object
def self.data=(data) @@raw_data = data process_data end.
- .columns ⇒ Object
- .columns_hash ⇒ Object
- .count(params = {}) ⇒ Object
- .data_storage=(ds) ⇒ Object
- .find(id) ⇒ Object
- .first ⇒ Object
- .new_from_hash(hsh) ⇒ Object
- .reflect_on_all_associations ⇒ Object
-
.widget_name=(w) ⇒ Object
def self.json=(str) @@data = ActiveSupport::JSON.decode(str) process_data end.
Instance Method Summary collapse
- #errors ⇒ Object
-
#id ⇒ Object
instance methods.
- #save ⇒ Object
Class Method Details
.all(params = {}) ⇒ Object
36 37 38 |
# File 'lib/netzke/field_model.rb', line 36 def self.all(params={}) @@data end |
.column_names ⇒ Object
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 |
.columns ⇒ Object
32 33 34 |
# File 'lib/netzke/field_model.rb', line 32 def self.columns column_names end |
.columns_hash ⇒ Object
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 |
.first ⇒ Object
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_associations ⇒ Object
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.(w) @@widget_name = w end |
Instance Method Details
#errors ⇒ Object
65 66 67 |
# File 'lib/netzke/field_model.rb', line 65 def errors [] end |
#id ⇒ Object
instance methods
61 62 63 |
# File 'lib/netzke/field_model.rb', line 61 def id self[:id] || self["id"] end |
#save ⇒ Object
69 70 71 |
# File 'lib/netzke/field_model.rb', line 69 def save true end |