Module: TinyDyno::Tables::ClassMethods
- Defined in:
- lib/tiny_dyno/tables.rb
Class Method Summary collapse
-
.option(option_name, &block) ⇒ Object
Stores the provided block to be run when the option name specified is defined on a field.
-
.options ⇒ Hash
Return a map of custom option names to their handlers.
Instance Method Summary collapse
-
#create_table ⇒ true
Send the actual table creation to the DynamoDB API.
-
#delete_table ⇒ true
Request the table to be deleted.
-
#model_table_config_is_valid? ⇒ String
Return the actual table name that represents the model in the DynamoDB store.
Class Method Details
.option(option_name, &block) ⇒ Object
Stores the provided block to be run when the option name specified is defined on a field.
No assumptions are made about what sort of work the handler might perform, so it will always be called if the option_name key is provided in the field definition – even if it is false or nil.
38 39 40 |
# File 'lib/tiny_dyno/tables.rb', line 38 def option(option_name, &block) [option_name] = block end |
.options ⇒ Hash
Return a map of custom option names to their handlers.
51 52 53 |
# File 'lib/tiny_dyno/tables.rb', line 51 def @options ||= {} end |
Instance Method Details
#create_table ⇒ true
Send the actual table creation to the DynamoDB API
60 61 62 63 |
# File 'lib/tiny_dyno/tables.rb', line 60 def create_table raise InvalidTableDefinition.new "#{ self.name } has invalid table configuration" unless model_table_config_is_valid? TinyDyno::Adapter.create_table(create_table_request) end |
#delete_table ⇒ true
Request the table to be deleted
70 71 72 |
# File 'lib/tiny_dyno/tables.rb', line 70 def delete_table TinyDyno::Adapter.delete_table(table_name: self.table_name) end |
#model_table_config_is_valid? ⇒ String
Return the actual table name that represents the model in the DynamoDB store
80 81 82 |
# File 'lib/tiny_dyno/tables.rb', line 80 def model_table_config_is_valid? return (attribute_definitions_meet_spec? and not self.table_name.nil?) end |