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 ]
- SYSTEM_TYPES =
%w{ lucidworkslogs }
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
- #system? ⇒ Boolean
Constructor Details
#initialize(crawler, attributes = {}) ⇒ DatasourceType
Returns a new instance of DatasourceType.
15 16 17 18 19 20 |
# File 'lib/lucid_works/datasource_type.rb', line 15 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.
13 14 15 |
# File 'lib/lucid_works/datasource_type.rb', line 13 def category @category end |
#crawler ⇒ Object (readonly)
Returns the value of attribute crawler.
13 14 15 |
# File 'lib/lucid_works/datasource_type.rb', line 13 def crawler @crawler end |
#props ⇒ Object (readonly)
Returns the value of attribute props.
13 14 15 |
# File 'lib/lucid_works/datasource_type.rb', line 13 def props @props end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/lucid_works/datasource_type.rb', line 13 def type @type end |
Instance Method Details
#default_attributes ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/lucid_works/datasource_type.rb', line 44 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
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/lucid_works/datasource_type.rb', line 26 def properties @properties ||= @props.map do |prop| DatasourceProperty.new(prop) end.tap do |properties| def properties.regular select {|p| !p.advanced? } end def properties.advanced select &:advanced? end end end |
#property(name) ⇒ Object
40 41 42 |
# File 'lib/lucid_works/datasource_type.rb', line 40 def property(name) properties.detect { |p| p.name == name } end |
#system? ⇒ Boolean
22 23 24 |
# File 'lib/lucid_works/datasource_type.rb', line 22 def system? SYSTEM_TYPES.include? type end |