Class: HyperAdmin::DSL::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/hyper_admin/dsl/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(resource_class) ⇒ Parser

Returns a new instance of Parser.



5
6
7
8
# File 'lib/hyper_admin/dsl/parser.rb', line 5

def initialize(resource_class)
  @resource_class = resource_class
  @config = { }
end

Instance Method Details

#form(&block) ⇒ Object



33
34
35
36
37
38
# File 'lib/hyper_admin/dsl/parser.rb', line 33

def form(&block)
  return unless block_given?

  dsl = HyperAdmin::DSL::Form.new @resource_class
  @config[:form_config] = dsl.instance_exec(&block)
end

#index(&block) ⇒ Object



26
27
28
29
30
31
# File 'lib/hyper_admin/dsl/parser.rb', line 26

def index(&block)
  return unless block_given?

  dsl = HyperAdmin::DSL::Index.new @resource_class
  @config[:index_config] = dsl.instance_exec(&block)
end

#parse(&block) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/hyper_admin/dsl/parser.rb', line 10

def parse(&block)
  return unless block_given?

  instance_exec(&block)

  @config
end

#show(&block) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/hyper_admin/dsl/parser.rb', line 18

def show(&block)
  return unless block_given?

  dsl = HyperAdmin::DSL::Show.new @resource_class
  
  @config[:show_config] = dsl.instance_exec(&block)
end