module RocketGate::Hashable::ClassMethods

Public Instance Methods

hashable(mapping_hash, *mergable_items) click to toggle source
# File lib/rocketgate/hashable.rb, line 3
def hashable(mapping_hash, *mergable_items)
  @mappings, @mergables = {}, []

  mapping_hash.each do |display_name, obj|
    if self.new.send(:is_callable?, obj)
      @mappings[display_name] = obj
    else
      raise RocketGate::ValidationError.new("Invalid attribute: #{obj}")
    end
  end

  mergable_items.each do |obj|
    if self.new.send(:is_callable?, obj)
      @mergables << obj
    else
      raise RocketGate::ValidationError.new("Invalid attribute: #{obj}")
    end
  end
end
mappings() click to toggle source
# File lib/rocketgate/hashable.rb, line 23
def mappings
  @mappings ||= {}
end
mergables() click to toggle source
# File lib/rocketgate/hashable.rb, line 27
def mergables
  @mergables ||= []
end