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)

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/active_scaffold/extensions/cow_proxy.rb', line 54

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

#respond_to_missing?(name) ⇒ Boolean

Returns:

  • (Boolean)

74
75
76
# File 'lib/active_scaffold/extensions/cow_proxy.rb', line 74

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