instance method superclass_delegating_accessor

Ruby on Rails 4.1.16

Since v2.2.3 Last seen in v4.2.9

Available in: v2.2.3 v2.3.18 v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9

Signature

superclass_delegating_accessor(name, options = {})

No documentation comment.

Parameters

name req
options opt = {}
Source
# File activesupport/lib/active_support/core_ext/class/delegating_attributes.rb, line 5
  def superclass_delegating_accessor(name, options = {})
    # Create private _name and _name= methods that can still be used if the public
    # methods are overridden.
    _superclass_delegating_accessor("_#{name}", options)

    # Generate the public methods name, name=, and name?.
    # These methods dispatch to the private _name, and _name= methods, making them
    # overridable.
    singleton_class.send(:define_method, name) { send("_#{name}") }
    singleton_class.send(:define_method, "#{name}?") { !!send("_#{name}") }
    singleton_class.send(:define_method, "#{name}=") { |value| send("_#{name}=", value) }

    # If an instance_reader is needed, generate public instance methods name and name?.
    if options[:instance_reader] != false
      define_method(name) { send("_#{name}") }
      define_method("#{name}?") { !!send("#{name}") }
    end
  end

Defined in activesupport/lib/active_support/core_ext/class/delegating_attributes.rb line 5 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Class

Type at least 2 characters to search.

↑↓ navigate · open · esc close