lib/jiralicious/parsers/field_parser.rb in jiralicious-0.2.0 vs lib/jiralicious/parsers/field_parser.rb in jiralicious-0.2.1
- old
+ new
@@ -1,9 +1,16 @@
# encoding: utf-8
module Jiralicious
module Parsers
+ ##
+ # The FieldParser module is an extention that assists in
+ # managing hash parsing and implementation.
+ #
module FieldParser
+ ##
+ # Parses an Array or Hash into the current class object.
+ #
def parse!(fields)
unless fields.is_a?(Hash)
raise ArgumentError
end
@jiralicious_field_parser_data = {}
@@ -30,15 +37,21 @@
end
end
private
+ ##
+ # Normalizes key names
+ #
def normalize(name)
name.gsub(/(\w+)([A-Z].*)/, '\1_\2').
gsub(/\W/, "_").
downcase
end
+ ##
+ # Converts Array or Hash to a Mash object
+ #
def mashify(data)
if data.is_a?(Array)
data.map { |d| mashify(d) }
elsif data.is_a?(Hash)
Hashie::Mash.new(data)