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.
112 113 114 |
# File 'lib/aliyun/log/record/field.rb', line 112 def attributes @attributes end |
Instance Method Details
#attribute_names ⇒ Object
94 95 96 |
# File 'lib/aliyun/log/record/field.rb', line 94 def attribute_names @attributes.keys end |
#evaluate_default_value(val) ⇒ Object
102 103 104 105 106 107 108 109 110 |
# File 'lib/aliyun/log/record/field.rb', line 102 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
98 99 100 |
# File 'lib/aliyun/log/record/field.rb', line 98 def has_attribute?(attr_name) @attributes.key?(attr_name.to_sym) end |
#read_attribute(name) ⇒ Object Also known as: []
120 121 122 |
# File 'lib/aliyun/log/record/field.rb', line 120 def read_attribute(name) attributes[name.to_sym] end |
#set_created_at ⇒ Object
125 126 127 |
# File 'lib/aliyun/log/record/field.rb', line 125 def set_created_at self.created_at ||= DateTime.now.in_time_zone(Time.zone).iso8601 if end |
#timestamps_enabled? ⇒ Boolean
129 130 131 |
# File 'lib/aliyun/log/record/field.rb', line 129 def self.class.[:timestamps] || (self.class.[:timestamps].nil? && Config.) end |
#write_attribute(name, value) ⇒ Object Also known as: []=
114 115 116 |
# File 'lib/aliyun/log/record/field.rb', line 114 def write_attribute(name, value) attributes[name.to_sym] = TypeCasting.cast_field(value, self.class.attributes[name.to_sym]) end |