Class: HALDecorator::Policy::DSL::Rules

Inherits:
Object
  • Object
show all
Defined in:
lib/hal_decorator/policy/dsl.rb

Instance Method Summary collapse

Instance Method Details

#add_attribute(name, block) ⇒ Object



31
32
33
# File 'lib/hal_decorator/policy/dsl.rb', line 31

def add_attribute(name, block)
  attributes[name] = block
end

#add_embed(name, block) ⇒ Object



47
48
49
# File 'lib/hal_decorator/policy/dsl.rb', line 47

def add_embed(name, block)
  embedded[name] = block
end


39
40
41
# File 'lib/hal_decorator/policy/dsl.rb', line 39

def add_link(rel, block)
  links[rel] = block
end

#attribute_rule_for(name) ⇒ Object



27
28
29
# File 'lib/hal_decorator/policy/dsl.rb', line 27

def attribute_rule_for(name)
  attributes[name]
end

#defaults(*types, value: false) ⇒ Object



21
22
23
24
25
# File 'lib/hal_decorator/policy/dsl.rb', line 21

def defaults(*types, value: false)
  types.each do |t|
    send(t).default= Proc.new { value }
  end
end

#embed_rule_for(name) ⇒ Object



43
44
45
# File 'lib/hal_decorator/policy/dsl.rb', line 43

def embed_rule_for(name)
  embedded[name]
end


35
36
37
# File 'lib/hal_decorator/policy/dsl.rb', line 35

def link_rule_for(rel)
  links[rel]
end