Sha256: b32b48b86959b520f99ce2a83f9c7dfa569a070ce1cb49bca167a0c859f27334
Contents?: true
Size: 724 Bytes
Versions: 2
Compression:
Stored size: 724 Bytes
Contents
class NetzkeLayout < ActiveRecord::Base UNRELATED_ATTRS = %w(created_at updated_at position layout_id) def self.user_id @@user_id ||= nil end def layout_items items_class.constantize.find_all_by_layout_id(id, :order => 'position') end def self.by_widget(widget_name) self.find(:first, :conditions => {:widget_name => widget_name, :user_id => self.user_id}) end def move_item(old_index, new_index) layout_item = layout_items[old_index] layout_item.remove_from_list layout_item.insert_at(new_index + 1) end def items_hash layout_items.map(&:attributes).map{|item| item.delete_if{|k,v| UNRELATED_ATTRS.include?(k)}}.map{ |i| i.convert_keys{ |k| k.to_sym } } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
netzke-core-0.2.0 | lib/app/models/netzke_layout.rb |
netzke-core-0.2.1 | lib/app/models/netzke_layout.rb |