Class: Lanes::Screen::Definition

Inherits:
Object
  • Object
show all
Includes:
Concerns::AttrAccessorWithDefault
Defined in:
lib/lanes/screen.rb

Instance Method Summary collapse

Constructor Details

#initialize(id, extension_id) ⇒ Definition

Returns a new instance of Definition.



101
102
103
104
105
# File 'lib/lanes/screen.rb', line 101

def initialize(id, extension_id)
    self.identifier = id
    @extension_id = extension_id
    @extension    = extension_id.underscore.camelize
end

Instance Method Details

#has_file_matching?(pattern) ⇒ Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/lanes/screen.rb', line 107

def has_file_matching?(pattern)
    Pathname.glob(root_path.join(pattern)).any?
end

#root_pathObject



111
112
113
114
115
# File 'lib/lanes/screen.rb', line 111

def root_path
    ext = Lanes::Extensions.for_identifier(@extension_id)
    raise "Unable to find extension '#{@extension_id}' for screen group" unless ext
    ext.root_path.join('client', url_prefix, identifier)
end

#to_jsonObject



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/lanes/screen.rb', line 121

def to_json
    Oj.dump({
                id:    identifier,
                title: title,
                icon:  icon,
                model: model_class,
                view:  view_class,
                js:    js,
                css:   css,
                assets: [js, css].reject{|asset| asset.blank? },
                access: model_access,
                group_id: group_id,
                extension: extension,
                url_prefix: url_prefix,
                description: description
            }, mode: :compat)
end

#url_path_for(type) ⇒ Object



117
118
119
# File 'lib/lanes/screen.rb', line 117

def url_path_for(type)
    "#{url_prefix}/#{self.send(type)}"
end