Class: CowProxy::ActiveScaffold::DataStructures::ActionLinks

Inherits:
Object
  • Object
show all
Defined in:
lib/active_scaffold/extensions/cow_proxy.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) {|subgroup| ... } ⇒ Object

Yields:

  • (subgroup)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# 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 =~ /[!?]$/
  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

Instance Method Details

#each(options = {}, &block) ⇒ Object



74
75
76
77
78
79
80
81
82
83
# 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

#respond_to_missing?(name) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/active_scaffold/extensions/cow_proxy.rb', line 70

def respond_to_missing?(name, *)
  name !~ /[!?]$/
end