Class: Yandex::Webmaster::Api::Attributes::AccessorBuilder
- Inherits:
-
Object
- Object
- Yandex::Webmaster::Api::Attributes::AccessorBuilder
show all
- Defined in:
- lib/yandex-webmaster/api/attributes/accessor_builder.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(object, attribute_name, type, options = {}) ⇒ AccessorBuilder
Returns a new instance of AccessorBuilder.
11
12
13
14
15
16
17
|
# File 'lib/yandex-webmaster/api/attributes/accessor_builder.rb', line 11
def initialize(object, attribute_name, type, options = {})
@object = object
@attribute_name = attribute_name
@type = type
@options = options.symbolize_keys
end
|
Instance Attribute Details
#attribute_name ⇒ Object
Returns the value of attribute attribute_name.
9
10
11
|
# File 'lib/yandex-webmaster/api/attributes/accessor_builder.rb', line 9
def attribute_name
@attribute_name
end
|
Returns the value of attribute object.
9
10
11
|
# File 'lib/yandex-webmaster/api/attributes/accessor_builder.rb', line 9
def object
@object
end
|
Returns the value of attribute options.
9
10
11
|
# File 'lib/yandex-webmaster/api/attributes/accessor_builder.rb', line 9
def options
@options
end
|
Returns the value of attribute type.
9
10
11
|
# File 'lib/yandex-webmaster/api/attributes/accessor_builder.rb', line 9
def type
@type
end
|
Instance Method Details
19
20
21
|
# File 'lib/yandex-webmaster/api/attributes/accessor_builder.rb', line 19
def accessor
raise NotImplementedError
end
|
#define_aliases ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/yandex-webmaster/api/attributes/accessor_builder.rb', line 31
def define_aliases
if self.type.respond_to?("default_#{self.accessor.to_s}_aliases")
self.type.send("default_#{self.accessor.to_s}_aliases", self.method_name).each do |alias_method_name|
self.object.send(:alias_method, alias_method_name, self.method_name)
end
end
end
|
#define_method ⇒ Object
27
28
29
|
# File 'lib/yandex-webmaster/api/attributes/accessor_builder.rb', line 27
def define_method
raise NotImplementedError
end
|
#instance_variable_name ⇒ Object
52
53
54
|
# File 'lib/yandex-webmaster/api/attributes/accessor_builder.rb', line 52
def instance_variable_name
self.options[:instance_variable_name] || "@#{self.attribute_name}"
end
|
#method_name ⇒ Object
23
24
25
|
# File 'lib/yandex-webmaster/api/attributes/accessor_builder.rb', line 23
def method_name
raise NotImplementedError
end
|
#method_name_from_options ⇒ Object
48
49
50
|
# File 'lib/yandex-webmaster/api/attributes/accessor_builder.rb', line 48
def method_name_from_options
(self.options[self.accessor].is_a?(Hash) && self.options[self.accessor][:name]) || self.options["#{self.accessor.to_s}_name".to_sym]
end
|
#method_visibility ⇒ Object
44
45
46
|
# File 'lib/yandex-webmaster/api/attributes/accessor_builder.rb', line 44
def method_visibility
self.method_visibility_from_options || :public
end
|
#method_visibility_from_options ⇒ Object
39
40
41
42
|
# File 'lib/yandex-webmaster/api/attributes/accessor_builder.rb', line 39
def method_visibility_from_options
return self.options[self.accessor] if self.options[self.accessor].present? && [:public, :protected, :private].include?(self.options[self.accessor])
(self.options[self.accessor].is_a?(Hash) && self.options[self.accessor][:visibility]) || self.options["#{self.accessor.to_s}_visibility".to_sym]
end
|