Module: Marley::Plugins::OrmRestConvenience::ClassMethods
- Defined in:
- lib/marley/plugins/orm_rest_convenience.rb
Instance Method Summary collapse
-
#authorize(verb) ⇒ Object
the next 2 will have to be overridden for most applications.
- #controller ⇒ Object
- #foreign_key_name ⇒ Object
- #list(params = {}) ⇒ Object
- #list_dataset(params = {}) ⇒ Object
- #reggae_instance_list(params = {}) ⇒ Object
- #requires_user? ⇒ Boolean
- #sti ⇒ Object
Instance Method Details
#authorize(verb) ⇒ Object
the next 2 will have to be overridden for most applications
24 |
# File 'lib/marley/plugins/orm_rest_convenience.rb', line 24 def (verb); send_or_default("authorize_#{verb}",true) ; end |
#controller ⇒ Object
22 |
# File 'lib/marley/plugins/orm_rest_convenience.rb', line 22 def controller; Marley::ModelController.new(self); end |
#foreign_key_name ⇒ Object
27 |
# File 'lib/marley/plugins/orm_rest_convenience.rb', line 27 def foreign_key_name; :"#{(respond_to?(:table_name) ? table_name : resource_name).to_s.singularize}_id"; end |
#list(params = {}) ⇒ Object
32 33 34 |
# File 'lib/marley/plugins/orm_rest_convenience.rb', line 32 def list(params={}) list_dataset(params).all end |
#list_dataset(params = {}) ⇒ Object
29 30 31 |
# File 'lib/marley/plugins/orm_rest_convenience.rb', line 29 def list_dataset(params={}) dataset.filter(params) end |
#reggae_instance_list(params = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/marley/plugins/orm_rest_convenience.rb', line 35 def reggae_instance_list(params={}) items=list(params) if items.length==0 Marley::ReggaeMessage.new(:title => 'Nothing Found') else cols=items[0].rest_cols Marley::ReggaeInstanceList.new( :name => resource_name, :schema => items[0].reggae_schema(true), :items => items.map{|i| cols.map{|c|i.send(c)}} ) end end |
#requires_user? ⇒ Boolean
25 |
# File 'lib/marley/plugins/orm_rest_convenience.rb', line 25 def requires_user?; false; end |