Class: AwsRecord::Generators::GeneratedAttribute Private
- Inherits:
-
Object
- Object
- AwsRecord::Generators::GeneratedAttribute
- Defined in:
- lib/generators/generated_attribute.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
- OPTS =
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[hkey rkey persist_nil db_attr_name ddb_type default_value].freeze
- INVALID_HKEY_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.
%i[map_attr list_attr numeric_set_attr string_set_attr].freeze
Instance Attribute Summary collapse
- #name ⇒ Object readonly private
- #options ⇒ Object private
- #type ⇒ Object readonly private
Class Method Summary collapse
Instance Method Summary collapse
- #column_name ⇒ Object private
- #field_type ⇒ Object private
- #human_name ⇒ Object private
-
#initialize(name, type = :string_attr, options = {}) ⇒ GeneratedAttribute
constructor
private
A new instance of GeneratedAttribute.
-
#password_digest? ⇒ Boolean
private
Methods used by rails scaffolding.
- #polymorphic? ⇒ Boolean private
Constructor Details
#initialize(name, type = :string_attr, options = {}) ⇒ GeneratedAttribute
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 GeneratedAttribute.
110 111 112 113 114 115 |
# File 'lib/generators/generated_attribute.rb', line 110 def initialize(name, type = :string_attr, = {}) @name = name @type = type @options = @digest = .delete(:digest) end |
Instance Attribute Details
#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.
9 10 11 |
# File 'lib/generators/generated_attribute.rb', line 9 def name @name end |
#options ⇒ 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.
10 11 12 |
# File 'lib/generators/generated_attribute.rb', line 10 def @options end |
#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.
9 10 11 |
# File 'lib/generators/generated_attribute.rb', line 9 def type @type end |
Class Method Details
.parse(field_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.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/generated_attribute.rb', line 23 def parse(field_definition) name, type, opts = field_definition.split(':') type ||= 'string' if OPTS.any? { |opt| type.include? opt } opts = type type = 'string' end opts = opts.split(',') if opts type, opts = (name, type, opts) validate_opt_combs(name, type, opts) new(name, type, opts) end |
Instance Method Details
#column_name ⇒ 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.
126 127 128 129 130 131 132 |
# File 'lib/generators/generated_attribute.rb', line 126 def column_name if @name == 'password_digest' 'password' else @name end end |
#field_type ⇒ 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.
12 13 14 15 16 17 18 19 20 |
# File 'lib/generators/generated_attribute.rb', line 12 def field_type case @type when :integer_attr then :number_field when :date_attr then :date_select when :datetime_attr then :datetime_select when :boolean_attr then :check_box else :text_field end end |
#human_name ⇒ 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.
134 135 136 |
# File 'lib/generators/generated_attribute.rb', line 134 def human_name name.humanize end |
#password_digest? ⇒ Boolean
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.
Methods used by rails scaffolding
118 119 120 |
# File 'lib/generators/generated_attribute.rb', line 118 def password_digest? @digest end |
#polymorphic? ⇒ Boolean
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.
122 123 124 |
# File 'lib/generators/generated_attribute.rb', line 122 def polymorphic? false end |