Class: BenchBloc::Bloc

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/bench_bloc/bloc/bloc.rb

Overview

Responsible for generating rake tasks from a hash and/or creating child Blocs

Direct Known Subclasses

Namespace, Task

Defined Under Namespace

Classes: Namespace, Task

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bloc_hash) ⇒ Bloc

Returns a new instance of Bloc.



7
8
9
# File 'lib/bench_bloc/bloc/bloc.rb', line 7

def initialize bloc_hash
  @bloc_hash, @bloc_namespaces = bloc_hash, []
end

Instance Attribute Details

#bloc_hashObject

Returns the value of attribute bloc_hash.



6
7
8
# File 'lib/bench_bloc/bloc/bloc.rb', line 6

def bloc_hash
  @bloc_hash
end

#bloc_namespacesObject

Returns the value of attribute bloc_namespaces.



6
7
8
# File 'lib/bench_bloc/bloc/bloc.rb', line 6

def bloc_namespaces
  @bloc_namespaces
end

Instance Method Details

#[](namespace_key) ⇒ Object



27
28
29
30
31
# File 'lib/bench_bloc/bloc/bloc.rb', line 27

def [](namespace_key)
  bench_bloc_namespace
    .bloc_namespaces
    .find { |bn| namespace_key == bn.namespace_key }
end

#generate_blocObject



11
12
13
14
15
16
17
18
19
# File 'lib/bench_bloc/bloc/bloc.rb', line 11

def generate_bloc
  bloc_namespaces.push(
    Bloc::Namespace.new(
      :bench_bloc,
      bloc_hash,
      true
    )
  )
end

#rake_blocObject



21
22
23
24
25
# File 'lib/bench_bloc/bloc/bloc.rb', line 21

def rake_bloc
  bloc_namespaces.each do |bn|
    bn.rake_namespace
  end
end