Module: LogStash::Modules::ResourceBase
- Included in:
- ElasticsearchResource, KibanaResource
- Defined in:
- lib/logstash/modules/resource_base.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#content_id ⇒ Object
readonly
Returns the value of attribute content_id.
-
#content_path ⇒ Object
readonly
Returns the value of attribute content_path.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #content ⇒ Object
- #content_as_object ⇒ Object
- #initialize(base, content_type, content_path, content = nil, content_id = nil) ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
7 8 9 |
# File 'lib/logstash/modules/resource_base.rb', line 7 def base @base end |
#content_id ⇒ Object (readonly)
Returns the value of attribute content_id.
7 8 9 |
# File 'lib/logstash/modules/resource_base.rb', line 7 def content_id @content_id end |
#content_path ⇒ Object (readonly)
Returns the value of attribute content_path.
7 8 9 |
# File 'lib/logstash/modules/resource_base.rb', line 7 def content_path @content_path end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
7 8 9 |
# File 'lib/logstash/modules/resource_base.rb', line 7 def content_type @content_type end |
Instance Method Details
#<=>(other) ⇒ Object
31 32 33 |
# File 'lib/logstash/modules/resource_base.rb', line 31 def <=>(other) to_s <=> other.to_s end |
#==(other) ⇒ Object
35 36 37 |
# File 'lib/logstash/modules/resource_base.rb', line 35 def ==(other) to_s == other.to_s end |
#content ⇒ Object
19 20 21 |
# File 'lib/logstash/modules/resource_base.rb', line 19 def content @content ||= FileReader.read(@content_path) end |
#content_as_object ⇒ Object
27 28 29 |
# File 'lib/logstash/modules/resource_base.rb', line 27 def content_as_object @content_as_object ||= FileReader.read_json(@content_path) rescue nil end |
#initialize(base, content_type, content_path, content = nil, content_id = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/logstash/modules/resource_base.rb', line 9 def initialize(base, content_type, content_path, content = nil, content_id = nil) @base, @content_type, @content_path = base, content_type, content_path @content_id = content_id || ::File.basename(@content_path, ".*") # content at this time will be a JSON string @content = content if !@content.nil? @content_as_object = LogStash::Json.load(@content) rescue {} end end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/logstash/modules/resource_base.rb', line 23 def to_s "#{base}, #{content_type}, #{content_path}, #{content_id}" end |