Class: LucidWorks::DatasourceType
- Inherits:
-
Object
- Object
- LucidWorks::DatasourceType
- Defined in:
- lib/lucid_works/datasource_type.rb
Constant Summary collapse
- DONT_INITIALIZE_PROPERTIES =
[ "collection", # not something we can provide a default for "name", # not something we can provide a default for "---" # Separator UI hint ]
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#crawler ⇒ Object
readonly
Returns the value of attribute crawler.
-
#props ⇒ Object
readonly
Returns the value of attribute props.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #default_attributes ⇒ Object
-
#initialize(crawler, attributes = {}) ⇒ DatasourceType
constructor
A new instance of DatasourceType.
- #properties ⇒ Object
- #property(name) ⇒ Object
Constructor Details
#initialize(crawler, attributes = {}) ⇒ DatasourceType
Returns a new instance of DatasourceType.
13 14 15 16 17 18 |
# File 'lib/lucid_works/datasource_type.rb', line 13 def initialize(crawler, attributes = {}) @crawler = crawler @category = attributes['category'] @type = attributes['type'] @props = attributes['props'] end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
11 12 13 |
# File 'lib/lucid_works/datasource_type.rb', line 11 def category @category end |
#crawler ⇒ Object (readonly)
Returns the value of attribute crawler.
11 12 13 |
# File 'lib/lucid_works/datasource_type.rb', line 11 def crawler @crawler end |
#props ⇒ Object (readonly)
Returns the value of attribute props.
11 12 13 |
# File 'lib/lucid_works/datasource_type.rb', line 11 def props @props end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/lucid_works/datasource_type.rb', line 11 def type @type end |
Instance Method Details
#default_attributes ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/lucid_works/datasource_type.rb', line 30 def default_attributes attrs = {}.with_indifferent_access properties.inject(attrs) do |hash, property| unless DONT_INITIALIZE_PROPERTIES.include?(property.name) || property.read_only? hash[property.name] = property.default_value end hash end attrs.merge!( :crawler => @crawler.name, :type => @type ) end |
#properties ⇒ Object
20 21 22 23 24 |
# File 'lib/lucid_works/datasource_type.rb', line 20 def properties @properties ||= @props.map do |prop| DatasourceProperty.new(prop) end end |
#property(name) ⇒ Object
26 27 28 |
# File 'lib/lucid_works/datasource_type.rb', line 26 def property(name) properties.detect { |p| p.name == name } end |