Sha256: 37d030b1cd0d438fb2bc626434608cc5ff184820084a473e37a18f691ee5aeef
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
module Smartfm::PublicContent def self.included(base) base.extend(ClassMethods) base.send(:include, InstanceMethods) end module ClassMethods def recent(params = {}) hash = self.rest_client.recent(params) self.deserialize(hash) || [] end def find(obj_id, params = {}) params[:id] = obj_id hash = self.rest_client.find(params) self.deserialize(hash) end def matching(keyword, params = {}) params[:keyword] = keyword hash = self.rest_client.matching(params) self.deserialize(hash) || [] end def create(auth, params = {}) self.new(params).save(auth) end def delete(obj_id) self.find(obj_id).delete end end module InstanceMethods def save(auth) result = self.rest_client.create(auth, self.to_post_data) case result when Hash self.deserialize(result) when String self.class.find(result) else true end end def delete(auth) self.rest_client.delete(auth, {:id => self.id}) end alias_method :destroy, :delete end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
nov-smartfm-1.0.2 | lib/smartfm/modules/public_content.rb |
smartfm-1.0.2 | lib/smartfm/modules/public_content.rb |