Class: Isomorphic::Node::ProcTo

Inherits:
AbstractNode show all
Defined in:
lib/isomorphic/node.rb

Instance Attribute Summary collapse

Attributes inherited from AbstractNode

#factory, #inflector, #options, #parent

Instance Method Summary collapse

Methods inherited from AbstractNode

#to_isomorphism_for

Methods included from Internal::DeepEquals

#all_attributes_eql?

Constructor Details

#initialize(parent, **options, &block) ⇒ ProcTo

Returns a new instance of ProcTo.



1117
1118
1119
1120
1121
# File 'lib/isomorphic/node.rb', line 1117

def initialize(parent, **options, &block)
  # super(parent, **options)

  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



1115
1116
1117
# File 'lib/isomorphic/node.rb', line 1115

def block
  @block
end

Instance Method Details

#from_isomorphism(scope, instance, record = nil, xmlattr_acc = ::ActiveSupport::HashWithIndifferentAccess.new) ⇒ Object



1123
1124
1125
# File 'lib/isomorphic/node.rb', line 1123

def from_isomorphism(scope, instance, record = nil, xmlattr_acc = ::ActiveSupport::HashWithIndifferentAccess.new)
  record
end

#to_isomorphism(scope, record, instance = nil) ⇒ Object



1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
# File 'lib/isomorphic/node.rb', line 1127

def to_isomorphism(scope, record, instance = nil)
  if block.nil?
    instance
  else
    case block.arity
      when 1 then block.call(record)
      when 2 then block.call(record, instance)
      when 3 then block.call(record, instance, scope)
      else record.instance_exec(instance, scope, &block)
    end
  end
end