Class: Osm::Event::Column
- Defined in:
- lib/osm/event.rb,
lib/osm/event.rb
Overview
Ensure the constant exists for the validators
Constant Summary collapse
- SORT_BY =
[:event, :id]
Instance Attribute Summary collapse
-
#id ⇒ String
OSM id for the column.
-
#label ⇒ String
Label to display in My.SCOUT (“” prevents display in My.SCOUT).
-
#name ⇒ String
Name for the column (displayed in OSM).
-
#parent_required ⇒ Boolean
Whether the parent is required to enter something.
Instance Method Summary collapse
-
#delete(api) ⇒ Boolean
Delete event column from OSM.
-
#initialize ⇒ Object
constructor
Initialize a new Column.
- #inspect ⇒ Object
-
#update(api) ⇒ Boolean
Update event column in OSM.
Methods inherited from Model
#<, #<=, #<=>, #>, #>=, #between?, #changed_attributes, configure, #reset_changed_attributes, #to_i
Constructor Details
#initialize ⇒ Object
Initialize a new Column
|
# File 'lib/osm/event.rb', line 659
|
Instance Attribute Details
#id ⇒ String
Returns OSM id for the column.
645 |
# File 'lib/osm/event.rb', line 645 attribute :id, :type => String |
#label ⇒ String
Returns label to display in My.SCOUT (“” prevents display in My.SCOUT).
645 |
# File 'lib/osm/event.rb', line 645 attribute :id, :type => String |
#name ⇒ String
Returns name for the column (displayed in OSM).
645 |
# File 'lib/osm/event.rb', line 645 attribute :id, :type => String |
#parent_required ⇒ Boolean
Returns whether the parent is required to enter something.
645 |
# File 'lib/osm/event.rb', line 645 attribute :id, :type => String |
Instance Method Details
#delete(api) ⇒ Boolean
Delete event column from OSM
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
# File 'lib/osm/event.rb', line 695 def delete(api) require_ability_to(api, :write, :events, event.section_id) data = api.perform_query("events.php?action=deleteColumn§ionid=#{event.section_id}&eventid=#{event.id}", { 'columnId' => id }) (ActiveSupport::JSON.decode(data['config']) || []).each do |i| return false if i['id'] == id end new_columns = [] event.columns.each do |column| new_columns.push(column) unless column == self end event.columns = new_columns cache_write(api, ['event', event.id], event) return true end |
#inspect ⇒ Object
716 717 718 |
# File 'lib/osm/event.rb', line 716 def inspect Osm.inspect_instance(self, ={:replace_with => {'event' => :id}}) end |
#update(api) ⇒ Boolean
Update event column in OSM
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
# File 'lib/osm/event.rb', line 667 def update(api) require_ability_to(api, :write, :events, event.section_id) data = api.perform_query("events.php?action=renameColumn§ionid=#{event.section_id}&eventid=#{event.id}", { 'columnId' => id, 'columnName' => name, 'pL' => label, 'pR' => (parent_required ? 1 : 0), }) (ActiveSupport::JSON.decode(data['config']) || []).each do |i| if i['id'] == id if i['name'].eql?(name) && (i['pL'].nil? || i['pL'].eql?(label)) && (i['pR'].eql?('1') == parent_required) reset_changed_attributes # The cached event will be out of date - remove it cache_delete(api, ['event', event.id]) # The cached event attedance will be out of date cache_delete(api, ['event_attendance', event.id]) return true end end end return false end |