Class: AttributedClass::MethodAttribute

Inherits:
Attribute show all
Defined in:
lib/attributed_class.rb

Constant Summary collapse

VISIBILITIES =
[ :private, :protected, :public, :unknown ]

Instance Attribute Summary collapse

Attributes inherited from Attribute

#default, #default_proc, #descr, #klass, #mandatory, #name

Instance Method Summary collapse

Methods inherited from Attribute

#compute_default, #help, #inspect, #invisible?, #mandatory?, set_default_proc, #to_form, #valid?, #visible?

Constructor Details

#initialize(name, descr, *args) ⇒ MethodAttribute

Returns a new instance of MethodAttribute.



153
154
155
156
157
158
# File 'lib/attributed_class.rb', line 153

def initialize ( name, descr, *args )
  vis = args.find { |arg| VISIBILITIES.include? arg }
  args.delete(vis) unless vis.nil?
  @visibility = vis || :unknown
  super(name, descr, *args)
end

Instance Attribute Details

#visibilityObject (readonly)

Returns the value of attribute visibility.



143
144
145
# File 'lib/attributed_class.rb', line 143

def visibility
  @visibility
end

Instance Method Details

#private?Boolean

Returns:

  • (Boolean)


144
145
146
# File 'lib/attributed_class.rb', line 144

def private?
  @visibility == :private
end

#protected?Boolean

Returns:

  • (Boolean)


147
148
149
# File 'lib/attributed_class.rb', line 147

def protected?
  @visibility == :protected
end

#public?Boolean

Returns:

  • (Boolean)


150
151
152
# File 'lib/attributed_class.rb', line 150

def public?
  @visibility == :public
end