Module Hashie::Extensions::IgnoreUndeclared
In: lib/hashie/extensions/ignore_undeclared.rb

IgnoreUndeclared is a simple mixin that silently ignores undeclared properties on initialization instead of raising an error. This is useful when using a Trash to capture a subset of a larger hash.

Note that attempting to retrieve an undeclared property will still raise a NoMethodError, even if a value for that property was provided at initialization.

@example

  class Person < Trash
    include Hashie::Extensions::IgnoreUndeclared

    property :first_name
    property :last_name
  end

  user_data = {
     :first_name => 'Freddy',
     :last_name => 'Nostrils',
     :email => 'freddy@example.com'
  }

  p = Person.new(user_data) # 'email' is silently ignored

  p.first_name # => 'Freddy'
  p.last_name  # => 'Nostrils'
  p.email      # => NoMethodError

Methods

Public Instance methods

[Validate]