class PropertyAccessor::PropertyBuilder

Attributes

property[R]

Public Class Methods

new(property) click to toggle source

@param property [PropertyAccessor::Property]

# File lib/property_accessor/property_builder.rb, line 12
def initialize(property)
  @property = property
end

Public Instance Methods

default(value = nil, &block) click to toggle source
# File lib/property_accessor/property_builder.rb, line 16
def default(value = nil, &block)
  if value
    property.default_value = value
  else
    property.default_value_proc = block
  end
end
get(method_name = nil, &block) click to toggle source

@param method_name [String, Symbol] override getter method name

# File lib/property_accessor/property_builder.rb, line 37
def get(method_name = nil, &block)
  if method_name
    property.getter_method_name = method_name
  end

  if block
    property.getter_proc = block
  else
    property.default_getter = true
  end

  @property.getter_method_name
end
private(method_name) click to toggle source
# File lib/property_accessor/property_builder.rb, line 24
def private(method_name)
  property.private_method_names << method_name
end
protected(method_name) click to toggle source
# File lib/property_accessor/property_builder.rb, line 28
def protected(method_name)
  property.protected_method_names << method_name
end
public(method_name) click to toggle source
# File lib/property_accessor/property_builder.rb, line 32
def public(method_name)
  property.public_method_names << method_name
end
set(method_name = nil, &block) click to toggle source

@param method_name [String, Symbol] override setter method name

# File lib/property_accessor/property_builder.rb, line 52
def set(method_name = nil, &block)
  if method_name
    property.setter_method_name = method_name
  end

  if block
    property.setter_proc = block
  else
    property.default_setter = true
  end

  property.setter_method_name
end