Class: Policy::CLI::Attribute Private

Inherits:
Object
  • Object
show all
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

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

.nameString

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

Returns:

  • (String)


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

Parameters:

  • source (String)

Returns:



# File 'lib/policy/cli/attribute.rb', line 12

.typeString

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

Returns:

  • (String)


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