Module: RailsConnector::Migrations::MigrationDsl
- Defined in:
- lib/rails_connector/migrations/migration_dsl.rb
Instance Method Summary collapse
-
#create_obj(attributes = {}) ⇒ Object
Creates a CMS object.
-
#create_obj_class(attributes = {}) ⇒ Object
Creates a CMS object class.
-
#delete_obj(id) ⇒ Object
Deletes a CMS object with the given id.
-
#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
Updates a CMS object.
-
#update_obj_class(id, attributes = {}) ⇒ Object
Updates a CMS object class.
-
#upload_file(file) ⇒ Object
Uploads a file to the content store.
Instance Method Details
#create_obj(attributes = {}) ⇒ Object
Creates a CMS object.
87 88 89 90 91 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 87 def create_obj(attributes = {}) endpoint = "workspaces/#{Workspace.current.id}/objs" CmsRestApi.post(endpoint, obj: attributes) end |
#create_obj_class(attributes = {}) ⇒ Object
Creates a CMS object class.
104 105 106 107 108 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 104 def create_obj_class(attributes = {}) endpoint = "workspaces/#{Workspace.current.id}/obj_classes" CmsRestApi.post(endpoint, obj_class: attributes) end |
#delete_obj(id) ⇒ Object
Deletes a CMS object with the given id.
120 121 122 123 124 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 120 def delete_obj(id) endpoint = "workspaces/#{Workspace.current.id}/objs/#{id}" CmsRestApi.delete(endpoint) end |
#get_obj(id) ⇒ Hash
Fetches all object attributes and their values.
136 137 138 139 140 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 136 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.
152 153 154 155 156 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 152 def get_obj_class(id) endpoint = "workspaces/#{Workspace.current.id}/obj_classes/#{id}" CmsRestApi.get(endpoint) end |
#update_obj(id, attributes = {}) ⇒ Object
Updates a CMS object.
169 170 171 172 173 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 169 def update_obj(id, attributes = {}) endpoint = "workspaces/#{Workspace.current.id}/objs/#{id}" CmsRestApi.put(endpoint, obj: attributes) end |
#update_obj_class(id, attributes = {}) ⇒ Object
Updates a CMS object class.
186 187 188 189 190 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 186 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
Uploads a file to the content store.
205 206 207 208 209 210 211 212 213 214 |
# File 'lib/rails_connector/migrations/migration_dsl.rb', line 205 def upload_file(file) = RailsConnector::CmsRestApi.get('blobs/upload_permission') fields = ['fields'].map { |name, value| [name, value] } fields << [:file, file] RestClient.post(['url'], fields) ['blob'] end |