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

Instance Method Summary collapse

Instance Attribute Details

#attributesObject

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_namesObject



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

Returns:

  • (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_atObject



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 timestamps_enabled?
end

#timestamps_enabled?Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/aliyun/log/record/field.rb', line 124

def timestamps_enabled?
  self.class.options[:timestamps] || (self.class.options[:timestamps].nil? && Config.timestamps)
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