lib/stair_master/step.rb in stair_master-0.0.3 vs lib/stair_master/step.rb in stair_master-0.1.0
- old
+ new
@@ -11,15 +11,10 @@
@conditions = build_conditions conditions
end
## Methods --------------------------------------------
- def available?(context)
- rules = @conditions[:availability]
- ( rules.empty? ? [true] : test_rules(rules, context) ).all?
- end
-
def skip?(context)
rules = @conditions[:skippable]
( rules.empty? ? [false] : test_rules(rules, context) ).all?
end
@@ -45,25 +40,22 @@
private # ---------------------------------------------
def build_conditions(conditions)
conditions = conditions.empty? ? {} : conditions.first
- availability_rules = []
skip_rules = []
conditions.each do |k,v|
condition_type, type = k.to_s.split('_').map{ |v| v.to_sym }
- if condition_type == :available ## It is an "availability" condition
- availability_rules << ::StairMaster::Conditions::Availability.new(self, type, v)
- elsif condition_type == :skip ## It is a "skip" condition
+ if condition_type == :skip ## It is a "skip" condition
skip_rules << ::StairMaster::Conditions::Skippable.new(self, type, v)
else
## We don't know what this type of condition is so raise an exception
raise RuntimeError, "Unknown type for: #{ k }"
end
end
- { availability: availability_rules, skippable: skip_rules }
+ { skippable: skip_rules }
end
end
end
\ No newline at end of file