Module: DaisybillApi::Ext::CRUD::ClassMethods
- Defined in:
- lib/daisybill_api/ext/crud.rb
Instance Method Summary collapse
- #client(method, path, params = {}) ⇒ Object
- #index_path(prefix_id) ⇒ Object
- #path ⇒ Object
- #path=(value) ⇒ Object
- #path_prefix(path, property) ⇒ Object
- #path_prefix? ⇒ Boolean
- #plural_key ⇒ Object
- #prefix_path ⇒ Object
- #prefix_property ⇒ Object
- #rest_actions(*actions) ⇒ Object
- #search_path(prefix_id) ⇒ Object
- #show_path(id) ⇒ Object
- #singular_key ⇒ Object
Instance Method Details
#client(method, path, params = {}) ⇒ Object
| 73 74 75 | # File 'lib/daisybill_api/ext/crud.rb', line 73 def client(method, path, params = {}) DaisybillApi::Data::Client.build method, path, params end | 
#index_path(prefix_id) ⇒ Object
| 61 62 63 64 65 66 67 | # File 'lib/daisybill_api/ext/crud.rb', line 61 def index_path(prefix_id) if path_prefix? index_path_with_prefix(prefix_id) else index_path_without_prefix end end | 
#path ⇒ Object
| 26 27 28 | # File 'lib/daisybill_api/ext/crud.rb', line 26 def path @path ||= "/#{plural_key}" end | 
#path=(value) ⇒ Object
| 22 23 24 | # File 'lib/daisybill_api/ext/crud.rb', line 22 def path=(value) @path = value end | 
#path_prefix(path, property) ⇒ Object
| 30 31 32 33 34 35 | # File 'lib/daisybill_api/ext/crud.rb', line 30 def path_prefix(path, property) @prefix_path = path @prefix_property = property attribute property, :integer, readonly: true validates property, presence: true, if: :new_record? end | 
#path_prefix? ⇒ Boolean
| 37 38 39 | # File 'lib/daisybill_api/ext/crud.rb', line 37 def path_prefix? !!(@prefix_path && @prefix_property) end | 
#plural_key ⇒ Object
| 49 50 51 | # File 'lib/daisybill_api/ext/crud.rb', line 49 def plural_key @plural_key ||= demodulize self.model_name.plural end | 
#prefix_path ⇒ Object
| 41 42 43 | # File 'lib/daisybill_api/ext/crud.rb', line 41 def prefix_path @prefix_path end | 
#prefix_property ⇒ Object
| 45 46 47 | # File 'lib/daisybill_api/ext/crud.rb', line 45 def prefix_property @prefix_property end | 
#rest_actions(*actions) ⇒ Object
| 14 15 16 17 18 19 20 | # File 'lib/daisybill_api/ext/crud.rb', line 14 def rest_actions(*actions) actions.each { |action| name = action.to_s.classify extend "DaisybillApi::Ext::CRUD::#{name}::ClassMethods".constantize include "DaisybillApi::Ext::CRUD::#{name}::InstanceMethods".constantize } end | 
#search_path(prefix_id) ⇒ Object
| 69 70 71 | # File 'lib/daisybill_api/ext/crud.rb', line 69 def search_path(prefix_id) "#{index_path(prefix_id)}/search" end | 
#show_path(id) ⇒ Object
| 57 58 59 | # File 'lib/daisybill_api/ext/crud.rb', line 57 def show_path(id) "#{path}/#{id}" end | 
#singular_key ⇒ Object
| 53 54 55 | # File 'lib/daisybill_api/ext/crud.rb', line 53 def singular_key @singular_key ||= demodulize self.model_name.singular end |