Module: RailsConnector::Migrations::MigrationDsl
- Defined in:
- lib/rails_connector/migrations/migration_dsl.rb
Instance Method Summary collapse
-
#create_obj(attributes = {}) ⇒ Object
deprecated
Deprecated.
use Obj.create instead
-
#create_obj_class(attributes = {}) ⇒ Object
Creates a CMS object class.
-
#delete_obj(id) ⇒ Object
deprecated
Deprecated.
use Obj#destroy instead
-
#get_obj(id) ⇒ Hash
Fetches all object attributes and their values.
-
#get_obj_class(id) ⇒ Hash
Fetches all object class attributes and their values.
-
#update_obj(id, attributes = {}) ⇒ Object
deprecated
Deprecated.
use Obj#update instead
-
#update_obj_class(id, attributes = {}) ⇒ Object
Updates a CMS object class.
-
#upload_file(file) ⇒ Object
deprecated
Deprecated.
use Obj.create or Obj#update instead
Instance Method Details
#create_obj(attributes = {}) ⇒ Object
Deprecated.
use Obj.create instead
Creates a CMS object.
89 90 91 92 93 94 95 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 89 def create_obj(attributes = {}) Deprecation.warn_method('create_obj', 'Obj.create') endpoint = "workspaces/#{Workspace.current.id}/objs" CmsRestApi.post(endpoint, obj: attributes) end |
#create_obj_class(attributes = {}) ⇒ Object
Creates a CMS object class.
108 109 110 111 112 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 108 def create_obj_class(attributes = {}) endpoint = "workspaces/#{Workspace.current.id}/obj_classes" CmsRestApi.post(endpoint, obj_class: attributes) end |
#delete_obj(id) ⇒ Object
Deprecated.
use Obj#destroy instead
Deletes a CMS object with the given id.
126 127 128 129 130 131 132 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 126 def delete_obj(id) Deprecation.warn_method('delete_obj', 'Obj#destroy') endpoint = "workspaces/#{Workspace.current.id}/objs/#{id}" CmsRestApi.delete(endpoint) end |
#get_obj(id) ⇒ Hash
Fetches all object attributes and their values.
144 145 146 147 148 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 144 def get_obj(id) endpoint = "workspaces/#{Workspace.current.id}/objs/#{id}" CmsRestApi.get(endpoint) end |
#get_obj_class(id) ⇒ Hash
Fetches all object class attributes and their values.
160 161 162 163 164 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 160 def get_obj_class(id) endpoint = "workspaces/#{Workspace.current.id}/obj_classes/#{id}" CmsRestApi.get(endpoint) end |
#update_obj(id, attributes = {}) ⇒ Object
Deprecated.
use Obj#update instead
Updates a CMS object.
179 180 181 182 183 184 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 179 def update_obj(id, attributes = {}) Deprecation.warn_method('update_obj', 'Obj#update') endpoint = "workspaces/#{Workspace.current.id}/objs/#{id}" CmsRestApi.put(endpoint, obj: attributes) end |
#update_obj_class(id, attributes = {}) ⇒ Object
Updates a CMS object class.
197 198 199 200 201 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 197 def update_obj_class(id, attributes = {}) endpoint = "workspaces/#{Workspace.current.id}/obj_classes/#{id}" CmsRestApi.put(endpoint, obj_class: attributes) end |
#upload_file(file) ⇒ Object
Deprecated.
use Obj.create or Obj#update instead
Uploads a file to the content store.
217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 217 def upload_file(file) Deprecation.warn_method("upload_file", "Obj.create or Obj#update") = RailsConnector::CmsRestApi.get('blobs/upload_permission') fields = ['fields'].map { |name, value| [name, value] } fields << [:file, file] RestClient.post(['url'], fields) ['blob'] end |