Class: Feature::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/toggles/feature/attribute.rb

Class Method Summary collapse

Class Method Details

.call(entity, attr_name, expected) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/toggles/feature/attribute.rb', line 2

def self.call(entity, attr_name, expected)
  if expected.kind_of? Hash
    expected.all? do |operation, rules|
      if Feature.operations.include? operation.to_sym
        Feature.operations[operation.to_sym].call(entity, attr_name, rules)
      else
        call(entity.send(attr_name), operation, rules)
      end
    end
  else
    entity.send(attr_name) == expected
  end
end