Class: Policy::CLI::Attribute Private
- Inherits:
-
Object
- Object
- Policy::CLI::Attribute
- Defined in:
- lib/policy/cli/attribute.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Decorates the string with #name and #type methods for described attribute
Class Method Summary collapse
- .initialize(source) ⇒ Object private
-
.name ⇒ String
private
The name of the attribute.
-
.new(source) ⇒ Policy::CLI::Attribute
Creates the decorator.
-
.type ⇒ String
private
The type of the attribute.
Class Method Details
.initialize(source) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/policy/cli/attribute.rb', line 21 def initialize(source) @source = source end |
.name ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The name of the attribute
28 29 30 31 32 33 |
# File 'lib/policy/cli/attribute.rb', line 28 def name @type ||= begin value = @source[/^\w+/] value ? value.snake_case : "@todo" end end |
.new(source) ⇒ Policy::CLI::Attribute
Creates the decorator
|
# File 'lib/policy/cli/attribute.rb', line 12
|
.type ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The type of the attribute
38 39 40 41 42 43 |
# File 'lib/policy/cli/attribute.rb', line 38 def type @type ||= begin value = @source[/(?<=\{)(.+)(?=\})/] value ? Hexx::CLI::Name.new(value).type : "@todo" end end |