Sha256: f5b0aef31a70db1bb57d41bc8da7b4c8361d0ed3ecd17b8319f2f2e052024e02
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
module SimpleMDM class App < Base def build(hash = nil) @dirty = false @binary_data = nil super end def self.all hash, code = fetch("apps") hash['data'].collect { |d| build d } end def self.find(id) hash, code = fetch("apps/#{id}") build hash['data'] end def binary=(val) raise "binary must be a File object" unless val.kind_of? File @dirty = true @binary_file = val end def name=(val) if val != self.name @dirty = true end self['name'] = val end def save if @dirty || new? params = {} params[:name] = self.name params[:binary] = @binary_file unless @binary_file.nil? if new? hash, code = fetch("apps", :post, params) self.id = hash['data']['id'] self.merge!(hash['data']['attributes']) else hash, code = fetch("apps/#{self.id}", :patch, params) end @dirty = false @binary_file = nil end self end def destroy raise "You cannot delete an app that hasn't been created yet." if new? hash, code = fetch("apps/#{self.id}", :delete) code == 204 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
simplemdm-0.2.0 | lib/simplemdm/app.rb |
simplemdm-0.1.1 | lib/simplemdm/app.rb |
simplemdm-0.1.0 | lib/simplemdm/app.rb |