Class: ClientData::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/client_data/builder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller = nil, options = {}) ⇒ Builder

Returns a new instance of Builder.



6
7
8
9
# File 'lib/client_data/builder.rb', line 6

def initialize(controller = nil, options = {})
  @controller = controller
  @options = options
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



3
4
5
# File 'lib/client_data/builder.rb', line 3

def controller
  @controller
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/client_data/builder.rb', line 4

def options
  @options
end

Class Method Details

.builder_nameObject



27
28
29
# File 'lib/client_data/builder.rb', line 27

def self.builder_name
  self.name.split('::').last.chomp('Builder').underscore
end

.properties(*props) ⇒ Object



11
12
13
14
15
# File 'lib/client_data/builder.rb', line 11

def self.properties(*props)
  props.each do |m|
    property(m)
  end
end

.property(prop) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/client_data/builder.rb', line 17

def self.property(prop)
  define_method(prop) do
    if controller.respond_to?(prop, true)
      controller.send(prop)
    else
      controller.instance_variable_get(:"@#{prop}")
    end
  end
end