Class: ActiveHash::Relation::Conditions

Inherits:
Object
  • Object
show all
Defined in:
lib/active_hash/conditions.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conditions = []) ⇒ Conditions

Returns a new instance of Conditions.



6
7
8
# File 'lib/active_hash/conditions.rb', line 6

def initialize(conditions = [])
  @conditions = conditions
end

Instance Attribute Details

#conditionsObject (readonly)

Returns the value of attribute conditions.



2
3
4
# File 'lib/active_hash/conditions.rb', line 2

def conditions
  @conditions
end

Class Method Details

.wrap(conditions) ⇒ Object



16
17
18
19
20
# File 'lib/active_hash/conditions.rb', line 16

def self.wrap(conditions)
  return conditions if conditions.is_a?(self)

  new(conditions)
end

Instance Method Details

#matches?(record) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
# File 'lib/active_hash/conditions.rb', line 10

def matches?(record)
  conditions.all? do |condition|
    condition.matches?(record)
  end
end