Class: SimpleMapper::Attribute::Pattern

Inherits:
SimpleMapper::Attribute show all
Includes:
Collection
Defined in:
lib/simple_mapper/attribute/pattern.rb

Constant Summary

Constants inherited from SimpleMapper::Attribute

Options

Instance Attribute Summary collapse

Attributes inherited from SimpleMapper::Attribute

#default, #key, #mapper, #name

Instance Method Summary collapse

Methods included from Collection

#apply_type, #changed?, #freeze_for, #from_simple_key, #new_collection, #source_value, #to_simple, #to_simple_key, #transformed_source_value

Methods inherited from SimpleMapper::Attribute

#change_tracking_for, #changed!, #changed?, #converter, #default_value, #encode, #freeze_for, #process_options, #source_value, #to_simple, #transformed_source_value, #type, #type=, #value

Constructor Details

#initialize(name, options = {}) ⇒ Pattern

Returns a new instance of Pattern.



6
7
8
9
# File 'lib/simple_mapper/attribute/pattern.rb', line 6

def initialize(name, options = {})
  super(name, options)
  self.pattern = options[:pattern]
end

Instance Attribute Details

#patternObject

Returns the value of attribute pattern.



4
5
6
# File 'lib/simple_mapper/attribute/pattern.rb', line 4

def pattern
  @pattern
end

Instance Method Details

#member_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/simple_mapper/attribute/pattern.rb', line 16

def member_key?(key)
  (pattern.match(key.to_s) and true) or false
end