module MWDictionaryAPI::Parsable::ClassMethods

Public Instance Methods

apply_rule(attr_name, data, options) click to toggle source
# File lib/mw_dictionary_api/parsable.rb, line 26
def apply_rule(attr_name, data, options)
  inherited_rules[attr_name][:block].call(data, options)
end
inherited_rules() click to toggle source
# File lib/mw_dictionary_api/parsable.rb, line 14
def inherited_rules
  if superclass.respond_to? :inherited_rules
    superclass.inherited_rules.merge(rules)
  else
    rules
  end
end
rule(attr_name, **options, &block) click to toggle source
# File lib/mw_dictionary_api/parsable.rb, line 22
def rule(attr_name, **options, &block)
  rules[attr_name] = { attr_name: attr_name, options: options, block: block }
end
rule_helpers(&block) click to toggle source
# File lib/mw_dictionary_api/parsable.rb, line 30
def rule_helpers(&block)
  instance_eval(&block)
end
rules() click to toggle source
# File lib/mw_dictionary_api/parsable.rb, line 10
def rules
  @rules ||= {}
end