Module: Aliyun::Log::Record::Field
- Extended by:
- ActiveSupport::Concern
- Included in:
- Aliyun::Log::Record
- Defined in:
- lib/aliyun/log/record/field.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- PERMITTED_KEY_TYPES =
Types allowed in indexes:
i[ text long double json ].freeze
- DEFAULT_INDEX_TOKEN =
", '\";=()[]{}?@&<>/:\n\t\r".split('')
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Instance Method Summary collapse
- #attribute_names ⇒ Object
- #evaluate_default_value(val) ⇒ Object
- #has_attribute?(attr_name) ⇒ Boolean
- #read_attribute(name) ⇒ Object (also: #[])
- #set_created_at ⇒ Object
- #timestamps_enabled? ⇒ Boolean
- #write_attribute(name, value) ⇒ Object (also: #[]=)
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
107 108 109 |
# File 'lib/aliyun/log/record/field.rb', line 107 def attributes @attributes end |
Instance Method Details
#attribute_names ⇒ Object
89 90 91 |
# File 'lib/aliyun/log/record/field.rb', line 89 def attribute_names @attributes.keys end |
#evaluate_default_value(val) ⇒ Object
97 98 99 100 101 102 103 104 105 |
# File 'lib/aliyun/log/record/field.rb', line 97 def evaluate_default_value(val) if val.respond_to?(:call) val.call elsif val.duplicable? val.dup else val end end |
#has_attribute?(attr_name) ⇒ Boolean
93 94 95 |
# File 'lib/aliyun/log/record/field.rb', line 93 def has_attribute?(attr_name) @attributes.key?(attr_name.to_sym) end |
#read_attribute(name) ⇒ Object Also known as: []
115 116 117 |
# File 'lib/aliyun/log/record/field.rb', line 115 def read_attribute(name) attributes[name.to_sym] end |
#set_created_at ⇒ Object
120 121 122 |
# File 'lib/aliyun/log/record/field.rb', line 120 def set_created_at self.created_at ||= DateTime.now.in_time_zone(Time.zone).iso8601 if end |
#timestamps_enabled? ⇒ Boolean
124 125 126 |
# File 'lib/aliyun/log/record/field.rb', line 124 def self.class.[:timestamps] || (self.class.[:timestamps].nil? && Config.) end |
#write_attribute(name, value) ⇒ Object Also known as: []=
109 110 111 |
# File 'lib/aliyun/log/record/field.rb', line 109 def write_attribute(name, value) attributes[name.to_sym] = TypeCasting.cast_field(value, self.class.attributes[name.to_sym]) end |