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

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



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

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

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



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

def field
  @field
end

#relationObject (readonly)

Returns the value of attribute relation.



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

def relation
  @relation
end

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Class Method Details

.kindObject



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

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

Instance Method Details

#clauseObject



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

def clause
  return @clause if defined?(@clause)    
  @clause ||= valid? ? _clause : nil
end

#invalid?Boolean

Returns:

  • (Boolean)


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

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

#parsedObject



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

def parsed
  value.to_s
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  !invalid?
end