Class: AwsRecord::Generators::SecondaryIndex Private
- Inherits:
-
Object
- Object
- AwsRecord::Generators::SecondaryIndex
- Defined in:
- lib/generators/secondary_index.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- PROJ_TYPES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%w[ALL KEYS_ONLY INCLUDE].freeze
Instance Attribute Summary collapse
- #hash_key ⇒ Object readonly private
- #name ⇒ Object readonly private
- #projection_type ⇒ Object readonly private
- #range_key ⇒ Object readonly private
Class Method Summary collapse
- .parse(key_definition) ⇒ Object private
Instance Method Summary collapse
-
#initialize(name, opts) ⇒ SecondaryIndex
constructor
private
A new instance of SecondaryIndex.
Constructor Details
#initialize(name, opts) ⇒ SecondaryIndex
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of SecondaryIndex.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/generators/secondary_index.rb', line 41 def initialize(name, opts) raise ArgumentError, 'You must provide a name' unless name raise ArgumentError, 'You must provide a hash key' unless opts[:hash_key] if opts.key? :projection_type unless PROJ_TYPES.include? opts[:projection_type] raise ArgumentError, "Invalid projection type #{opts[:projection_type]}" end if opts[:projection_type] != 'ALL' raise NotImplementedError, 'ALL is the only projection type currently supported' end else opts[:projection_type] = 'ALL' end if opts[:hash_key] == opts[:range_key] raise ArgumentError, "#{opts[:hash_key]} cannot be both the rkey and hkey for gsi #{name}" end @name = name @hash_key = opts[:hash_key] @range_key = opts[:range_key] @projection_type = "\"#{opts[:projection_type]}\"" end |
Instance Attribute Details
#hash_key ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/generators/secondary_index.rb', line 8 def hash_key @hash_key end |
#name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/generators/secondary_index.rb', line 8 def name @name end |
#projection_type ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/generators/secondary_index.rb', line 8 def projection_type @projection_type end |
#range_key ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/generators/secondary_index.rb', line 8 def range_key @range_key end |
Class Method Details
.parse(key_definition) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 14 15 16 17 |
# File 'lib/generators/secondary_index.rb', line 11 def parse(key_definition) name, = key_definition.split(':') = .split(',') if opts = () new(name, opts) end |