Module: Isomorphic::Node::Internal::InstanceMethodsForMember
- Extended by:
- ActiveSupport::Concern
- Included in:
- Association, Attribute, Element, GuardMember, Member, Namespace, RootMember
- Defined in:
- lib/isomorphic/node.rb
Overview
Included when the base class is a member.
Instance Method Summary collapse
-
#attribute(method_name, isomorphism_xmlattr_class = nil, **options) {|node| ... } ⇒ self
Build an Isomorphic node for an attribute.
-
#attribute_for(lens_or_attribute_name, method_name, isomorphism_xmlattr_class = nil, **options) {|node| ... } ⇒ self
Build an Isomorphic node for an attribute using the given lens.
-
#collection(method_name, isomorphism_class, **options) {|node| ... } ⇒ self
Build an Isomorphic node for a collection.
-
#from(**options) {|instance, record, xmlattr_acc, scope| ... } ⇒ self
Build an Isomorphic node for a
Proc
that is called in the reverse direction only. -
#guard_attribute_for(lens_or_attribute_name, *values, **options) {|node| ... } ⇒ self
Build an Isomorphic node for a “guard” statement for an attribute using an Isomorphic lens.
-
#member(method_name, isomorphism_class, **options) {|node| ... } ⇒ self
Build an Isomorphic node for a member.
-
#namespace(namespace, lens_or_attribute_name, **options) {|node| ... } ⇒ self
Build an Isomorphic node for a “namespace” statement using an Isomorphic lens.
-
#namespace_attribute_for(namespace, terms, method_name, isomorphism_xmlattr_class = nil, **options) {|node| ... } ⇒ self
Build an Isomorphic node for a value of a “namespace” statement that is within scope.
-
#to(**options) {|record, instance, scope| ... } ⇒ self
Build an Isomorphic node for a
Proc
that is called in the forward direction only.
Instance Method Details
#attribute(method_name, isomorphism_xmlattr_class = nil, **options) {|node| ... } ⇒ self
Build an Isomorphic node for an attribute.
235 236 237 238 239 |
# File 'lib/isomorphic/node.rb', line 235 def attribute(method_name, isomorphism_xmlattr_class = nil, **, &block) node = Isomorphic::Node::Attribute.new(self, method_name, isomorphism_xmlattr_class, **, &block) @__child_nodes << node node end |
#attribute_for(lens_or_attribute_name, method_name, isomorphism_xmlattr_class = nil, **options) {|node| ... } ⇒ self
Build an Isomorphic node for an attribute using the given lens.
252 253 254 255 256 257 258 259 |
# File 'lib/isomorphic/node.rb', line 252 def attribute_for(lens_or_attribute_name, method_name, isomorphism_xmlattr_class = nil, **, &block) lens = lens_or_attribute_name.is_a?(Isomorphic::Lens::AbstractLens) ? lens_or_attribute_name : reflect_on_attribute(lens_or_attribute_name) attribute(method_name, isomorphism_xmlattr_class, **.merge({ get: ::Proc.new { |record| lens.get(record) }, set: ::Proc.new { |record, value, xmlattr_acc| lens.set(record, value, xmlattr_acc) }, }), &block) end |
#collection(method_name, isomorphism_class, **options) {|node| ... } ⇒ self
Build an Isomorphic node for a collection.
271 272 273 274 275 |
# File 'lib/isomorphic/node.rb', line 271 def collection(method_name, isomorphism_class, **, &block) node = Isomorphic::Node::Collection.new(self, method_name, isomorphism_class, **, &block) @__child_nodes << node node end |
#from(**options) {|instance, record, xmlattr_acc, scope| ... } ⇒ self
Build an Isomorphic node for a Proc
that is called in the reverse direction only.
286 287 288 289 290 |
# File 'lib/isomorphic/node.rb', line 286 def from(**, &block) node = Isomorphic::Node::ProcFrom.new(self, **, &block) @__child_nodes << node node end |
#guard_attribute_for(lens_or_attribute_name, *values, **options) {|node| ... } ⇒ self
Build an Isomorphic node for a “guard” statement for an attribute using an Isomorphic lens.
303 304 305 306 307 308 309 |
# File 'lib/isomorphic/node.rb', line 303 def guard_attribute_for(lens_or_attribute_name, *values, **, &block) lens = lens_or_attribute_name.is_a?(Isomorphic::Lens::AbstractLens) ? lens_or_attribute_name : reflect_on_attribute(lens_or_attribute_name) node = Isomorphic::Node::GuardMember.new(self, lens, *values, **, &block) @__child_nodes << node node end |
#member(method_name, isomorphism_class, **options) {|node| ... } ⇒ self
Build an Isomorphic node for a member.
321 322 323 324 325 |
# File 'lib/isomorphic/node.rb', line 321 def member(method_name, isomorphism_class, **, &block) node = Isomorphic::Node::Member.new(self, method_name, isomorphism_class, **, &block) @__child_nodes << node node end |
#namespace(namespace, lens_or_attribute_name, **options) {|node| ... } ⇒ self
Build an Isomorphic node for a “namespace” statement using an Isomorphic lens.
337 338 339 340 341 342 343 |
# File 'lib/isomorphic/node.rb', line 337 def namespace(namespace, lens_or_attribute_name, **, &block) lens = lens_or_attribute_name.is_a?(Isomorphic::Lens::AbstractLens) ? lens_or_attribute_name : reflect_on_attribute(lens_or_attribute_name) node = Isomorphic::Node::Namespace.new(self, namespace, lens, **, &block) @__child_nodes << node node end |
#namespace_attribute_for(namespace, terms, method_name, isomorphism_xmlattr_class = nil, **options) {|node| ... } ⇒ self
Build an Isomorphic node for a value of a “namespace” statement that is within scope.
358 359 360 361 362 363 364 |
# File 'lib/isomorphic/node.rb', line 358 def namespace_attribute_for(namespace, terms, method_name, isomorphism_xmlattr_class = nil, **, &block) key = inflector.isomorphism(terms) node = Isomorphic::Node::NamespaceAttribute.new(self, namespace, key, method_name, isomorphism_xmlattr_class, **, &block) @__child_nodes << node node end |
#to(**options) {|record, instance, scope| ... } ⇒ self
Build an Isomorphic node for a Proc
that is called in the forward direction only.
374 375 376 377 378 |
# File 'lib/isomorphic/node.rb', line 374 def to(**, &block) node = Isomorphic::Node::ProcTo.new(self, **, &block) @__child_nodes << node node end |