Module: RecurringSelect
- Defined in:
- lib/recurring_select.rb,
lib/recurring_select/engine.rb,
lib/recurring_select/version.rb
Defined Under Namespace
Classes: Engine
Constant Summary collapse
- VERSION =
"3.0.1"
Class Method Summary collapse
Class Method Details
.dirty_hash_to_rule(params) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/recurring_select.rb', line 6 def self.dirty_hash_to_rule(params) if params.is_a? IceCube::Rule params else params = JSON.parse(params, quirks_mode: true) if params.is_a?(String) if params.nil? nil else params = params.symbolize_keys rules_hash = filter_params(params) IceCube::Rule.from_hash(rules_hash) end end end |
.is_valid_rule?(possible_rule) ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/recurring_select.rb', line 22 def self.is_valid_rule?(possible_rule) return true if possible_rule.is_a?(IceCube::Rule) return false if possible_rule.blank? if possible_rule.is_a?(String) begin return JSON.parse(possible_rule).is_a?(Hash) rescue JSON::ParserError return false end end # TODO: this should really have an extra step where it tries to perform the final parsing return true if possible_rule.is_a?(Hash) false #only a hash or a string of a hash can be valid end |