Method: Osm::Term.create
- Defined in:
- lib/osm/term.rb
.create(api, options = {}) ⇒ Boolean
Create a term in OSM
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/osm/term.rb', line 131 def self.create(api, ={}) raise ArgumentError, ":section can't be nil" if [:section].nil? raise ArgumentError, ":name can't be nil" if [:name].nil? raise ArgumentError, ":start can't be nil" if [:start].nil? raise ArgumentError, ":finish can't be nil" if [:finish].nil? require_access_to_section(api, [:section]) api_data = { 'term' => [:name], 'start' => [:start].strftime(Osm::OSM_DATE_FORMAT), 'end' => [:finish].strftime(Osm::OSM_DATE_FORMAT), 'termid' => '0' } data = api.perform_query("users.php?action=addTerm§ionid=#{options[:section].to_i}", api_data) # The cached terms for the section will be out of date - remove them get_all(api, ).each do |term| cache_delete(api, ['term', term.id]) if term.section_id == section_id end cache_delete(api, ['terms', api.user_id]) return data.is_a?(Hash) && data['terms'].is_a?(Hash) end |