Class: KirguduBase::DynamicPages::DataSourceBuilder
- Inherits:
-
Builder
- Object
- Builder
- KirguduBase::DynamicPages::DataSourceBuilder
- Defined in:
- app/models/kirgudu_base/dynamic_pages/data_source_builder.rb
Instance Method Summary collapse
- #cache_locally(value) ⇒ Object
- #cross_domain(value) ⇒ Object
- #data_format(value) ⇒ Object
- #http_method(value) ⇒ Object
-
#initialize(&block) ⇒ DataSourceBuilder
constructor
A new instance of DataSourceBuilder.
- #label_property(value) ⇒ Object
- #model(value) ⇒ Object
- #to_element ⇒ Object
- #type(value) ⇒ Object
- #url(value) ⇒ Object
- #url_path(controller, action, params = {}) ⇒ Object
- #value_property(value) ⇒ Object
Constructor Details
#initialize(&block) ⇒ DataSourceBuilder
Returns a new instance of DataSourceBuilder.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/kirgudu_base/dynamic_pages/data_source_builder.rb', line 5 def initialize(&block) raise "Cannot Build Empty Data Source" unless block_given? self..merge!( { model: nil, cross_domain: nil, url: nil, data_format: nil, label_property: :name, value_property: :id, cache_locally: nil, type: nil, http_method: nil } ) super(&block) end |
Instance Method Details
#cache_locally(value) ⇒ Object
58 59 60 |
# File 'app/models/kirgudu_base/dynamic_pages/data_source_builder.rb', line 58 def cache_locally(value) self.[:cache_locally] = value end |
#cross_domain(value) ⇒ Object
30 31 32 |
# File 'app/models/kirgudu_base/dynamic_pages/data_source_builder.rb', line 30 def cross_domain(value) self.[:cross_domain] = value end |
#data_format(value) ⇒ Object
46 47 48 |
# File 'app/models/kirgudu_base/dynamic_pages/data_source_builder.rb', line 46 def data_format(value) self.[:data_format] = value end |
#http_method(value) ⇒ Object
67 68 69 |
# File 'app/models/kirgudu_base/dynamic_pages/data_source_builder.rb', line 67 def http_method(value) self.[:http_method] = value end |
#label_property(value) ⇒ Object
50 51 52 |
# File 'app/models/kirgudu_base/dynamic_pages/data_source_builder.rb', line 50 def label_property(value) self.[:label_property] = value end |
#model(value) ⇒ Object
26 27 28 |
# File 'app/models/kirgudu_base/dynamic_pages/data_source_builder.rb', line 26 def model(value) self.[:model] = value end |
#to_element ⇒ Object
72 73 74 75 76 77 |
# File 'app/models/kirgudu_base/dynamic_pages/data_source_builder.rb', line 72 def to_element element = ::KirguduBase::DynamicPages::DataSource.new self.build_element(element) self.validate_generated_element(element) element end |
#type(value) ⇒ Object
62 63 64 |
# File 'app/models/kirgudu_base/dynamic_pages/data_source_builder.rb', line 62 def type(value) self.[:type] = value end |
#url(value) ⇒ Object
34 35 36 |
# File 'app/models/kirgudu_base/dynamic_pages/data_source_builder.rb', line 34 def url(value) self.[:url] = value end |
#url_path(controller, action, params = {}) ⇒ Object
38 39 40 41 42 43 44 |
# File 'app/models/kirgudu_base/dynamic_pages/data_source_builder.rb', line 38 def url_path(controller, action, params = {}) self.[:url_path] = { controller: controller, action: action, params: params } end |
#value_property(value) ⇒ Object
54 55 56 |
# File 'app/models/kirgudu_base/dynamic_pages/data_source_builder.rb', line 54 def value_property(value) self.[:value_property] = value end |