Sha256: b08b1ff284f20addf808ff05c3a3774285ad8b1b0d54cb089b3342f6f402333a
Contents?: true
Size: 1.98 KB
Versions: 18
Compression:
Stored size: 1.98 KB
Contents
module KirguduBase module DynamicPages class DataSource < ::KirguduBase::DynamicPages::Element mergeable_attributes :model, :cross_domain, :cache_locally, :url, :data_format, :label_property, :value_property, :type, :http_method validates_presence_of :model, :type, :label_property, :value_property validates_presence_of :url, :http_method, if: :is_internet_data_source? validates_inclusion_of :type, in: ::KirguduBase::DynamicPages::Enums::SUPPORTED_DATA_SOURCE_TYPES, allow_nil: true validates_inclusion_of :data_format, in: ::KirguduBase::DynamicPages::Enums::SUPPORTED_DATA_FORMATS, allow_nil: true, message: "This Format is not supported. Supported Data Formats are #{::KirguduBase::DynamicPages::Enums::SUPPORTED_DATA_FORMATS.map { |i| ":#{i}" }.join(", ")}" validates_inclusion_of :cross_domain, in: [:true, :false], allow_nil: true validates_inclusion_of :cache_locally, in: [:true, :false], allow_nil: true def initialize(options = {}) self.model = nil self.cross_domain = :false self.cache_locally = :false self.url = nil self.data_format = :json self.label_property = :name self.value_property = :id self.type = :local self.http_method = nil super(options) end attr_accessor :model attr_accessor :cross_domain attr_accessor :cache_locally attr_accessor :url attr_accessor :data_format attr_accessor :label_property attr_accessor :value_property attr_accessor :type attr_accessor :http_method def to_external_hash(options = {}) options ||= {} options.merge!({ url: self.url, data_format: self.data_format, http_method: self.http_method, label_property: self.label_property, value_property: self.value_property }) super(options) end def is_internet_data_source? self.type == :jquery || self.type == :jquery_db || self.type == :remote end end end end
Version data entries
18 entries across 18 versions & 1 rubygems