Class: Prosereflect::Transform::DocAttrStep
- Defined in:
- lib/prosereflect/transform/attr_step.rb
Overview
Set or remove document-level attributes
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
Class Method Summary collapse
Instance Method Summary collapse
- #apply(doc) ⇒ Object
- #get_map ⇒ Object
-
#initialize(attrs) ⇒ DocAttrStep
constructor
A new instance of DocAttrStep.
- #invert(doc) ⇒ Object
- #step_type ⇒ Object
- #to_json(*_args) ⇒ Object
Methods inherited from Step
Constructor Details
#initialize(attrs) ⇒ DocAttrStep
Returns a new instance of DocAttrStep.
108 109 110 111 |
# File 'lib/prosereflect/transform/attr_step.rb', line 108 def initialize(attrs) super() @attrs = attrs end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
106 107 108 |
# File 'lib/prosereflect/transform/attr_step.rb', line 106 def attrs @attrs end |
Class Method Details
.from_json(_schema, json) ⇒ Object
139 140 141 |
# File 'lib/prosereflect/transform/attr_step.rb', line 139 def self.from_json(_schema, json) new(json["attrs"]) end |
Instance Method Details
#apply(doc) ⇒ Object
113 114 115 116 117 118 |
# File 'lib/prosereflect/transform/attr_step.rb', line 113 def apply(doc) new_doc = set_doc_attrs(doc) Result.ok(new_doc) rescue StandardError => e Result.fail(e.) end |
#get_map ⇒ Object
120 121 122 |
# File 'lib/prosereflect/transform/attr_step.rb', line 120 def get_map StepMap.new end |
#invert(doc) ⇒ Object
124 125 126 127 |
# File 'lib/prosereflect/transform/attr_step.rb', line 124 def invert(doc) old_attrs = get_old_doc_attrs(doc) DocAttrStep.new(old_attrs) end |
#step_type ⇒ Object
129 130 131 |
# File 'lib/prosereflect/transform/attr_step.rb', line 129 def step_type "setDocAttr" end |
#to_json(*_args) ⇒ Object
133 134 135 136 137 |
# File 'lib/prosereflect/transform/attr_step.rb', line 133 def to_json(*_args) json = super json["attrs"] = @attrs json end |