class Cliches::Definition

A class that holds the basic definition of a cliche.

Attributes

name[R]
value[R]

Public Class Methods

find(name) click to toggle source

Finds the definition with a given name. Returns nil if it there is none.

# File lib/cliches/definition.rb, line 26
def self.find(name)
  definitions[name.to_sym]
end
new(name) click to toggle source

Initialize a cliche with the given name and set its value to an empty hash.

name will be converted to a symbol

# File lib/cliches/definition.rb, line 15
def initialize(name)
  @name = name.to_sym
  @value = {}
end

Private Class Methods

definitions() click to toggle source
# File lib/cliches/definition.rb, line 38
def self.definitions
  @definitions ||= {}
end
reset!() click to toggle source
# File lib/cliches/definition.rb, line 42
def self.reset!
  @definitions = {}
end

Public Instance Methods

as(value) click to toggle source

Set the value of a definition as being value.

# File lib/cliches/definition.rb, line 21
def as(value)
  @value = value
end
register() click to toggle source

Registers a definition. This will override any existing definition with the same name.

# File lib/cliches/definition.rb, line 31
def register
  self.class.definitions[name] = self
  self
end