Class: Bsm::Constrainable::Operation::Base

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::Memoizable
Defined in:
lib/bsm/constrainable/operation/base.rb

Direct Known Subclasses

Between, Collection, Eq, Gt, Gteq, Lt, Lteq, Matches, NotEq

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, relation, field) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
# File 'lib/bsm/constrainable/operation/base.rb', line 10

def initialize(value, relation, field)
  @value    = value
  @relation = relation
  @field    = field
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



8
9
10
# File 'lib/bsm/constrainable/operation/base.rb', line 8

def field
  @field
end

#relationObject (readonly)

Returns the value of attribute relation.



8
9
10
# File 'lib/bsm/constrainable/operation/base.rb', line 8

def relation
  @relation
end

#valueObject (readonly)

Returns the value of attribute value.



8
9
10
# File 'lib/bsm/constrainable/operation/base.rb', line 8

def value
  @value
end

Class Method Details

.kindObject



4
5
6
# File 'lib/bsm/constrainable/operation/base.rb', line 4

def self.kind
  name.demodulize.underscore.to_sym
end

Instance Method Details

#clauseObject



29
30
31
# File 'lib/bsm/constrainable/operation/base.rb', line 29

def clause
  valid? ? _clause : nil
end

#invalid?Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/bsm/constrainable/operation/base.rb', line 24

def invalid?
  wrap = Array.wrap(normalized)
  wrap.empty? || wrap.any?(&:nil?)
end

#parsedObject



16
17
18
# File 'lib/bsm/constrainable/operation/base.rb', line 16

def parsed
  value.to_s
end

#valid?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/bsm/constrainable/operation/base.rb', line 20

def valid?
  !invalid?
end