Class: ActiveGraph::Shared::FilteredHash

Inherits:
Object
  • Object
show all
Defined in:
lib/active_graph/shared/filtered_hash.rb

Defined Under Namespace

Classes: InvalidHashFilterType

Constant Summary collapse

VALID_SYMBOL_INSTRUCTIONS =
[:all, :none]
VALID_HASH_INSTRUCTIONS =
[:on]
VALID_INSTRUCTIONS_TYPES =
[Hash, Symbol]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, instructions) ⇒ FilteredHash

Returns a new instance of FilteredHash.



10
11
12
13
14
15
# File 'lib/active_graph/shared/filtered_hash.rb', line 10

def initialize(base, instructions)
  @base = base
  @instructions = instructions
  @instructions_type = instructions.class
  validate_instructions!(instructions)
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



8
9
10
# File 'lib/active_graph/shared/filtered_hash.rb', line 8

def base
  @base
end

#instructionsObject (readonly)

Returns the value of attribute instructions.



8
9
10
# File 'lib/active_graph/shared/filtered_hash.rb', line 8

def instructions
  @instructions
end

#instructions_typeObject (readonly)

Returns the value of attribute instructions_type.



8
9
10
# File 'lib/active_graph/shared/filtered_hash.rb', line 8

def instructions_type
  @instructions_type
end

Instance Method Details

#filtered_baseObject



17
18
19
20
21
22
23
24
# File 'lib/active_graph/shared/filtered_hash.rb', line 17

def filtered_base
  case instructions
  when Symbol
    filtered_base_by_symbol
  when Hash
    filtered_base_by_hash
  end
end