lib/mite-rb.rb in mite-rb-0.2.0 vs lib/mite-rb.rb in mite-rb-0.2.1
- old
+ new
@@ -59,11 +59,11 @@
self.protocol = 'http'
self.port = ''
class MethodNotAvaible < StandardError; end
- module NoWriteAccess
+ module ResourceWithoutWriteAccess
def save
raise MethodNotAvaible, "Cannot save #{self.class.name} over mite.api"
end
def create
@@ -73,10 +73,26 @@
def destroy
raise MethodNotAvaible, "Cannot save #{self.class.name} over mite.api"
end
end
+ module ResourceWithActiveArchived
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ module ClassMethods
+ def archived(options={})
+ find(:all, options.update(:from => :archived))
+ end
+
+ def active(options={})
+ find(:all, options)
+ end
+ end
+ end
+
class Base < ActiveResource::Base
class << self
def inherited(base)
unless base == Mite::SingletonBase
@@ -90,11 +106,11 @@
super
end
# Common shortcuts known from ActiveRecord
def all(options={})
- find_every(options)
+ find(:all, options)
end
def first(options={})
find_every(options).first
end
@@ -104,10 +120,10 @@
end
end
end
class SingletonBase < Base
- include NoWriteAccess
+ include ResourceWithoutWriteAccess
class << self
def collection_name
element_name
end
\ No newline at end of file