Module: TinyDyno::Fields::ClassMethods
- Defined in:
- lib/tiny_dyno/fields.rb
Instance Method Summary collapse
-
#attribute_names ⇒ Array<String>
Returns an array of names for the attributes available on this object.
-
#database_field_name(name) ⇒ String
Get the name of the provided field as it is stored in the database.
-
#field(name, options = {}) ⇒ Field
Defines all the fields that are accessible on the Document For each field that is defined, a getter and setter will be added as an instance method to the Document.
Instance Method Details
#attribute_names ⇒ Array<String>
Returns an array of names for the attributes available on this object.
Provides the field names in an ORM-agnostic way. Rails v3.1+ uses this method to automatically wrap params in JSON requests.
81 82 83 |
# File 'lib/tiny_dyno/fields.rb', line 81 def attribute_names fields.keys end |
#database_field_name(name) ⇒ String
Get the name of the provided field as it is stored in the database. Used in determining if the field is aliased or not.
96 97 98 99 |
# File 'lib/tiny_dyno/fields.rb', line 96 def database_field_name(name) return nil unless name normalized = name.to_s end |
#field(name, options = {}) ⇒ Field
Defines all the fields that are accessible on the Document For each field that is defined, a getter and setter will be added as an instance method to the Document.
116 117 118 119 120 |
# File 'lib/tiny_dyno/fields.rb', line 116 def field(name, = {}) named = name.to_s added = add_field(named, ) added end |