Class: RbsActivesupport::AttributeAccessor
- Inherits:
-
Object
- Object
- RbsActivesupport::AttributeAccessor
- Defined in:
- lib/rbs_activesupport/attribute_accessor.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
: Symbol.
-
#options ⇒ Object
readonly
: Hash[untyped, untyped].
Instance Method Summary collapse
-
#default? ⇒ Boolean
: boolish.
-
#default_type ⇒ Object
: String.
-
#included? ⇒ Boolean
: bool.
-
#initialize(name, options) ⇒ AttributeAccessor
constructor
A new instance of AttributeAccessor.
-
#instance_accessor? ⇒ Boolean
: bool.
-
#instance_reader? ⇒ Boolean
: bool.
-
#instance_writer? ⇒ Boolean
: bool.
-
#private? ⇒ Boolean
: bool.
-
#public? ⇒ Boolean
: bool.
-
#singleton_reader? ⇒ Boolean
: bool.
-
#singleton_writer? ⇒ Boolean
: bool.
-
#type ⇒ Object
: String.
Constructor Details
#initialize(name, options) ⇒ AttributeAccessor
Returns a new instance of AttributeAccessor.
10 11 12 13 |
# File 'lib/rbs_activesupport/attribute_accessor.rb', line 10 def initialize(name, ) #: void @name = name = end |
Instance Attribute Details
#name ⇒ Object (readonly)
: Symbol
5 6 7 |
# File 'lib/rbs_activesupport/attribute_accessor.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
: Hash[untyped, untyped]
6 7 8 |
# File 'lib/rbs_activesupport/attribute_accessor.rb', line 6 def end |
Instance Method Details
#default? ⇒ Boolean
: boolish
47 48 49 |
# File 'lib/rbs_activesupport/attribute_accessor.rb', line 47 def default? #: boolish .fetch(:default, nil) end |
#default_type ⇒ Object
: String
51 52 53 54 |
# File 'lib/rbs_activesupport/attribute_accessor.rb', line 51 def default_type #: String default = .fetch(:default, nil) RbsActivesupport::Types.guess_type(default) end |
#included? ⇒ Boolean
: bool
64 65 66 |
# File 'lib/rbs_activesupport/attribute_accessor.rb', line 64 def included? #: bool .fetch(:included, false) end |
#instance_accessor? ⇒ Boolean
: bool
35 36 37 |
# File 'lib/rbs_activesupport/attribute_accessor.rb', line 35 def instance_accessor? #: bool .fetch(:instance_accessor, true) end |
#instance_reader? ⇒ Boolean
: bool
39 40 41 |
# File 'lib/rbs_activesupport/attribute_accessor.rb', line 39 def instance_reader? #: bool .fetch(:instance_reader, instance_accessor?) end |
#instance_writer? ⇒ Boolean
: bool
43 44 45 |
# File 'lib/rbs_activesupport/attribute_accessor.rb', line 43 def instance_writer? #: bool .fetch(:instance_writer, instance_accessor?) end |
#private? ⇒ Boolean
: bool
60 61 62 |
# File 'lib/rbs_activesupport/attribute_accessor.rb', line 60 def private? #: bool .fetch(:private, false) end |
#public? ⇒ Boolean
: bool
56 57 58 |
# File 'lib/rbs_activesupport/attribute_accessor.rb', line 56 def public? #: bool !private? end |
#singleton_reader? ⇒ Boolean
: bool
27 28 29 |
# File 'lib/rbs_activesupport/attribute_accessor.rb', line 27 def singleton_reader? #: bool .fetch(:singleton_reader, true) end |
#singleton_writer? ⇒ Boolean
: bool
31 32 33 |
# File 'lib/rbs_activesupport/attribute_accessor.rb', line 31 def singleton_writer? #: bool .fetch(:singleton_writer, true) end |
#type ⇒ Object
: String
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rbs_activesupport/attribute_accessor.rb', line 15 def type #: String # @type var trailing_comment: String? trailing_comment = [:trailing_comment] if trailing_comment&.start_with?("#:") trailing_comment[2..].strip elsif default? default_type else "untyped" end end |