Class: RKit::Dsl::Base

Inherits:
Object show all
Includes:
Thrust
Defined in:
lib/r_kit/dsl/base.rb,
lib/r_kit/dsl/base/thrust.rb

Defined Under Namespace

Modules: LocalParams, Thrust Classes: Params, Readonly

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base) ⇒ Base

Returns a new instance of Base.



12
13
14
15
16
17
18
19
20
21
# File 'lib/r_kit/dsl/base.rb', line 12

def initialize base
  @base = base
  @methods = Hash.new{ |hash, key| hash[key] = proc{} }

  @methods[:allowance] = proc{ true }
  @methods[:restriction] = proc{ raise DslStandardError.new(self, method_name: __method__) }
  # TODO: the __method__ return 'initialize', and not the "acts_as_..." that it shoul

  @params = RKit::Dsl::Base::Params.new(->(){})
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



10
11
12
# File 'lib/r_kit/dsl/base.rb', line 10

def base
  @base
end

Class Method Details

.dslsObject



4
5
6
# File 'lib/r_kit/dsl/base.rb', line 4

def self.dsls
  @dsls
end

Instance Method Details

#allowed?(&block) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/r_kit/dsl/base.rb', line 61

def allowed? &block
  methods :allowance, &block
end

#before(&block) ⇒ Object



49
50
51
52
53
# File 'lib/r_kit/dsl/base.rb', line 49

def before &block
  methods :before, &block

  thrust_dsl_callback!
end

#domain(domain) ⇒ Object

Raises:



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/r_kit/dsl/base.rb', line 34

def domain domain
  raise DslDefinitionError.new(@base) if [@name, @method].none?

  @domain ||= domain

  shadow domain: domain do |shadow_self|
    thrust_dsl!
    thrust_dsl_callback! if @methods[:before]
    thrust_dsl_interface!
    thrust_dsl_options!
    thrust_dsl_extend!
  end
end

#method(method) ⇒ Object



29
30
31
# File 'lib/r_kit/dsl/base.rb', line 29

def method method
  @method = method
end

#methods(context, &block) ⇒ Object



69
70
71
# File 'lib/r_kit/dsl/base.rb', line 69

def methods context, &block
  @methods[context] = block
end

#name(name) ⇒ Object

TODO: vérifier l’unicité du “name”



25
26
27
# File 'lib/r_kit/dsl/base.rb', line 25

def name name
  @name = name
end

#params(params_lambda) ⇒ Object



56
57
58
# File 'lib/r_kit/dsl/base.rb', line 56

def params params_lambda
  @params = RKit::Dsl::Base::Params.new(params_lambda)
end

#restricted(&block) ⇒ Object



65
66
67
# File 'lib/r_kit/dsl/base.rb', line 65

def restricted &block
  methods :restriction, &block
end