class Osm::FlexiRecord::Column
Public Instance Methods
<=>(another)
click to toggle source
Compare Column
based on flexi_record then id
# File lib/osm/flexi_record.rb, line 214 def <=>(another) result = self.flexi_record <=> another.try(:flexi_record) if result == 0 if id.match(/\Af_\d+\Z/) # This is a user column unless another.try(:id).to_s.match(/\Af_\d+\Z/) return 1 end else # This is a system column if another.try(:id).to_s.match(/\Af_\d+\Z/) return -1 end end result = self.id <=> another.try(:id) end return result end
delete(api)
click to toggle source
Delete a column in OSM @param [Osm::Api] api The api to use to make the request @return [Boolean] whether the column was deleted from OSM @raise [Osm::Forbidden] If this Column
is not editable
# File lib/osm/flexi_record.rb, line 191 def delete(api) require_ability_to(api, :write, :flexi, flexi_record.section_id) raise Osm::Forbidden, 'this column is not editable' unless self.editable data = api.perform_query("extras.php?action=deleteColumn§ionid=#{flexi_record.section_id}&extraid=#{flexi_record.id}", { 'columnId' => self.id, }) if (data.is_a?(Hash) && data.has_key?('config')) ActiveSupport::JSON.decode(data['config']).each do |f| if f['id'] == self.id # It wasn't deleted return false end end end # The cached columns for the flexi record will be out of date - remove them cache_delete(api, ['flexi_record_columns', flexi_record.id]) return true end
inspect()
click to toggle source
# File lib/osm/flexi_record.rb, line 233 def inspect Osm.inspect_instance(self, options={:replace_with => {'flexi_record' => :id}}) end
update(api)
click to toggle source
Update a column in OSM @param [Osm::Api] api The api to use to make the request @return [Boolean] whether the column was updated in OSM @raise [Osm::ObjectIsInvalid] If the Column
is invalid @raise [Osm::Forbidden] If the COlumn is not editable
# File lib/osm/flexi_record.rb, line 164 def update(api) raise Osm::ObjectIsInvalid, 'column is invalid' unless valid? require_ability_to(api, :write, :flexi, flexi_record.section_id) raise Osm::Forbidden, 'this column is not editable' unless self.editable data = api.perform_query("extras.php?action=renameColumn§ionid=#{flexi_record.section_id}&extraid=#{flexi_record.id}", { 'columnId' => self.id, 'columnName' => self.name, }) if (data.is_a?(Hash) && data.has_key?('config')) ActiveSupport::JSON.decode(data['config']).each do |f| if (f['id'] == self.id) && (f['name'] == self.name) reset_changed_attributes # The cached columns for the flexi record will be out of date - remove them cache_delete(api, ['flexi_record_columns', flexi_record.id]) return true end end end return false end