class CowProxy::ActiveScaffold::DataStructures::ActionLinks

Public Instance Methods

each(options = {}) { |item, instance_variable_get(:set)| ... } click to toggle source
Calls superclass method
# File lib/active_scaffold/extensions/cow_proxy.rb, line 74
def each(options = {}, &block)
  super(options) do |item|
    item = __wrap__(item) || item unless item.is_a?(ActiveScaffold::DataStructures::ActionLinks)
    if options[:include_set]
      yield item, __getobj__.instance_variable_get(:@set)
    else
      yield item
    end
  end
end
method_missing(name, *args) { |subgroup| ... } click to toggle source
Calls superclass method
# File lib/active_scaffold/extensions/cow_proxy.rb, line 50
def method_missing(name, *args, &block)
  CowProxy.debug { "method missing #{name} in #{__getobj__.name}" }
  return super if name.match?(/[!?]$/)
  subgroup =
    if _instance_variable_defined?("@#{name}")
      _instance_variable_get("@#{name}")
    else
      __copy_on_write__ if __getobj__.frozen?
      group = __getobj__.subgroup(name, args.first)
      if group.frozen?
        group = __wrap__(group)
      else
        CowProxy.debug { "created subgroup #{group.name}" }
      end
      _instance_variable_set("@#{name}", group)
    end
  yield subgroup if block
  subgroup
end
respond_to_missing?(name, *) click to toggle source
# File lib/active_scaffold/extensions/cow_proxy.rb, line 70
def respond_to_missing?(name, *)
  name !~ /[!?]$/
end

Protected Instance Methods

__copy_on_write__(*) click to toggle source

Copy wrapped values to duplicated wrapped object @see CowProxy::Base#copy_on_write @return duplicated wrapped object

Calls superclass method
# File lib/active_scaffold/extensions/cow_proxy.rb, line 90
def __copy_on_write__(*)
  index = @parent_proxy.instance_variable_get(:@set).index(__getobj__) if @parent_proxy
  super.tap do
    CowProxy.debug { "replace #{index} with proxy obj in parent #{@parent_proxy.name}" } if index
    @parent_proxy.instance_variable_get(:@set)[index] = self if index
    new_set = __getobj__.instance_variable_get(:@set).dup
    __getobj__.instance_variable_set(:@set, new_set)
  end
end