Class: Inject::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/inject/rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, identifier, value, **options) ⇒ Rule

Returns a new instance of Rule.



4
5
6
7
8
9
# File 'lib/inject/rule.rb', line 4

def initialize(key, identifier, value, **options)
  @key = key
  @identifier = identifier
  @value = value
  @options = options
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



2
3
4
# File 'lib/inject/rule.rb', line 2

def identifier
  @identifier
end

#keyObject (readonly)

Returns the value of attribute key.



2
3
4
# File 'lib/inject/rule.rb', line 2

def key
  @key
end

#optionsObject (readonly)

Returns the value of attribute options.



2
3
4
# File 'lib/inject/rule.rb', line 2

def options
  @options
end

#valueObject (readonly)

Returns the value of attribute value.



2
3
4
# File 'lib/inject/rule.rb', line 2

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Object



11
12
13
14
15
16
# File 'lib/inject/rule.rb', line 11

def <=>(other)
  # this one has before: :all or before: other
  [other.identifier, :all].include?(self.options[:before]) ||
    # other one has after: :all, or after: self
    [self.identifier, :all].include?(other.options[:after])
end