Class: Fusuma::Plugin::Events::Records::IndexRecord
- Defined in:
- lib/fusuma/plugin/events/records/index_record.rb
Overview
Vector Record have index
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
define gesture format.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Instance Method Summary collapse
-
#initialize(index:, position: :body) ⇒ IndexRecord
constructor
A new instance of IndexRecord.
- #mergable? ⇒ Boolean
- #merge(records:) ⇒ IndexRecord
- #type ⇒ Object
Methods inherited from Base
#config_index, #config_param_types, #config_params, inherited, plugins
Constructor Details
#initialize(index:, position: :body) ⇒ IndexRecord
Returns a new instance of IndexRecord.
16 17 18 19 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 16 def initialize(index:, position: :body) @index = index @position = position end |
Instance Attribute Details
#index ⇒ Object (readonly)
define gesture format
11 12 13 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 11 def index @index end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
12 13 14 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 12 def position @position end |
Instance Method Details
#mergable? ⇒ Boolean
43 44 45 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 43 def mergable? @position == :body end |
#merge(records:) ⇒ IndexRecord
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 27 def merge(records:) raise "position is NOT body: #{self}" unless mergable? @index = records.reduce(@index) do |merged_index, record| case record.position when :prefix Config::Index.new([*record.index.keys, *merged_index.keys]) when :surfix Config::Index.new([*merged_index.keys, *record.index.keys]) else raise "invalid index position: #{record}" end end self end |
#type ⇒ Object
21 22 23 |
# File 'lib/fusuma/plugin/events/records/index_record.rb', line 21 def type :index end |